[Tutor] Cannot understand object initiation

ALAN GAULD alan.gauld at btinternet.com
Mon Oct 14 15:39:07 CEST 2013



I tried experimenting with classes and objects on python interpretor
>and learned that in python functions, classes, method, objects and
>modules all can be passed around and returned.That's correct, they are all objects in Python


From what I understood from your answers:
>
>user = User.query.filter_by ( username = self.username.data ).first()
>
>returns a reference to an instance of class User. So user is an object
>of type User class.Not necessarily. first() can return any kind of object. It just seems likely 
that in this case it will be a User. But it depends entirely on how the 
first() method of whatever object User.query.filter_by() is implemented.

Also, db is an sqlalchemy engine and db.Model is a class.
>
>db.Model is I think a sqlalchemy declarative base class which has all
>the needed methods and classes for database handling.
>
>Possibly but you'll need someone who knows SQLAlchemy better than 
me to answer definitively

Alan G.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131014/31b25feb/attachment.html>


More information about the Tutor mailing list