Sunday 15 September 2013

Python Class __init__ Not Working -


This is a really simple code that I'm using with sqlalchemy and I have some basic memory about it. How the classes work.

  class game (base): __tablename__ = "games" id = column (integer, primary_key = true) a_name = column (string) def __init __ (self, ** kwargs): k For .iteritems (): In kwargs, the Satetrer (Self, K, V) print 'Hi' itself. Hey_dictor = {'name': self. A_Name} @Hebrid_Property DEF stuff (self): return self Here_desker   

The following query works:

  session.query (game) .first (). A_name   

but the following query returns an error:

  session.query (game) .first (). There is no special feature in the 'game' object: 'away_dictionary'   

I have another basic problem, when I ask the game class then it does not print 'hi' Can anyone please explain that every time I use 'Game' why not 'Hi' does not print? And the second question is how can I build a distant sequence for each instance of this class and how can I reach it?

Ah, I was telling that it is strange that stuff is not Is getting, and I hope that away_dictionary was not replaced by this ... and you edited your post and changed the error message that you are quoting. It is not really getting remote word , because it is normally made in your class's __init __ () method and __init __ () is not calling.

Generally, when you make an example, then __init __ () is called, but when you use class in SQLLame queries Leaving __ init __ () method I suspect that there is something similar to working with SQLLame's declarative_mapper , but I am ample enough on SQLite I do not know how to fix it on top of my head. If I have come to know, then I will edit this reply later and tell you.

But now, you should not rely on your __init __ () method which is something derived from your SQLite model objects (i.e., Base ) as well). See if you can make your code any other way.

No comments:

Post a Comment