How to subclass datetime?
Alex Martelli
aleax at aleax.it
Sun Apr 13 12:34:59 EDT 2003
<posted & mailed>
Jane Austine wrote:
> Running Python 2.3a2 on win XP.
>
> I'm interested in the new datetime module and I want to subclass
> date/datetime class to modify the behaviour. However, simply
> inheritting the classes(like "class mydate(date):" ) didn't work.
Please define "didn't work"...:
>>> import datetime
>>> class mydate(datetime.date):
... pass
...
>>> xx=mydate(2003,4,14)
>>> print xx
2003-04-14
>>>
Seems to be working just fine. What exactly isn't working for you?
> Should I resort to delegation?
Maybe, but it's hard to say unless you can be more specific!
Alex
More information about the Python-list
mailing list