The Voidspace Techie Blog

You could make it easier by just using a property:

from datetime import datetime

class current_datetime(object):
....def __get__(self, instance, owner):
........return owner.now()

class new_datetime(datetime):
....current = current_datetime()

>>> new_datetime.current
new_datetime(2007, 10, 12, 18, 27, 57, 748366)


Gravatar Cool - and it is more readable than the metaclass solution. Thanks


Name:

Email:

URL:

Comment:  ? 

 

Commenting by HaloScan