peter wrote: >> >>> from datetime import * >> >>> class TS(datetime): >> >> ... def __new__(cls, ts): >> ... return datetime.fromtimestamp(ts) >> ...>>> TS(0) >> >> datetime.datetime(1970, 1, 1, 1, 0) >> >> works super() would be the most likely culprit. > > Yes, that works, except the returned object is (unsurprisingly) a pure > datetime instance, which means I cannot access any other attributes I > defined on my class.
How about import datetime class DT(datetime.datetime): def __new__(cls, *args): if len(args) == 1: return cls.fromtimestamp(args[0]) return datetime.datetime.__new__(cls, *args) then? Peter -- http://mail.python.org/mailman/listinfo/python-list