How to read the Python tutorial?

Zeynel azeynel1 at gmail.com
Wed Nov 10 17:05:55 CET 2010


On Nov 10, 10:51 am, rantingrick <rantingr... at gmail.com> wrote:

> Wait a minute i am confused...? Does Python have a "text" object that
> magically turns into a datetime object?
>
> >>> mDATE = 2010-11-10 14:35:22.863000
>
> SyntaxError: invalid syntax

This is the reason I am asking the question. I am confused about what
mDATE is. It is defined as a DateTimeProperty in Google App Engine in
the following model:

class Rep(db.Model):
    mAUTHOR = db.UserProperty(auto_current_user=True)
    mUNIQUE = db.StringProperty()
    mCOUNT = db.IntegerProperty()
    mDATE = db.DateTimeProperty(auto_now=True)
    mDATE0 = db.DateTimeProperty(auto_now_add=True)
    mWEIGHT = db.IntegerProperty()


When I acces it with this query:

QUERY = Rep.all()
        QUERY.filter("mAUTHOR =", user)
        QUERY.order("-mCOUNT")
        RESULTS = QUERY.fetch(10)

But when I try to use like this for instance:

for result in RESULTS:
    WEIGHT = (datetime.datetime.result.mDATE.toordinal()) *
result.mCOUNT

I get AttributeError

or if I try to use it like this

dt = result.mDATE.seconds

I get

AttributeError: 'datetime.datetime' object has no attribute 'seconds'




More information about the Python-list mailing list