sub-classing the types in the builtin module datetime
mamrhein at users.sourceforge.net
Wed Aug 15 19:03:20 CEST 2007
Colin J. Williams wrote:
> I wish to sub-class (if that's the right word) datetime and to use a
> different signature for the constructor.
> The second part has gone smoothly, but it is difficult to access the
> type's methods from the sub-class instance.
>>> from datetime import datetime
>>> class mydt(datetime): pass
mydt(2007, 8, 15, 18, 57, 58, 562000)
How did you overwrite the constuctor?
Are you sure your constructor really returns a subclass of datetime?
> I'm beginning to wonder whether it might might be simpler to write my
> own Date class.
If you only want to change the signature of the constuctor, just write a
> Does anyone have any comments please?
> Colin W.
More information about the Python-list