I need a Class attribute that sets datetime.now() when instantiating a new instance of the class. With this code, MyThing.created seems to always be when MyThing imported, and not when mt is created.
from datetime import datetime class MyThing: __init__(self, created=datetime.now()): self.created = created MyThing.created datetime.datetime(2012, 7, 5, 10, 54, 24, 865791) mt = MyThing() mt.created datetime.datetime(2012, 7, 5, 10, 54, 24, 865791)
How can I do this so that created created by mt and not MyThing ?
source share