Overloading ctor doesn't work?
dwt23 at hotmail.com
Thu Jan 20 19:23:35 CET 2005
I just tried to run this code and failed miserably - though I dunno why.
Could any of you please enlighten me why this doesn't work?
Thanks a bunch.
--- snip ---
from datetime import datetime
class time (datetime):
def __init__(self, hours=0, minutes=0, seconds=0, microseconds=0):
datetime.__init__(self, 1, 1, 1, hours, \
minutes, seconds, microseconds)
class Test (unittest.TestCase):
# print time() # bombs, and complains that
# the time ctor needs at least 3 arguments
if __name__ == '__main__':
--- snap ---
The reason I want to do this is that I want to work with times but I
want to do arithmetic with them. Therefore I cannot use the provided
Now I thought, just overide the ctor of datetime so that year, month and
day are static and everything should work as far as I need it.
That is, it could work - though I seem to be unable to overide the ctor. :(
Why is that?
Reach me at spamfaenger (at) gmx (dot) net
More information about the Python-list