Overloading ctor doesn't work?
francis.girard at free.fr
Thu Jan 20 14:31:24 EST 2005
Now, this is serious. I tried all sort of things but can't solve the problem.
I'm mystified too and forget my last reply.
I'm curious to see the answers.
Le jeudi 20 Janvier 2005 19:59, Kent Johnson a écrit :
> > Martin Häcker wrote:
> >> Hi there,
> >> 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?
> Here is a simpler test case. I'm mystified too:
> from datetime import datetime
> class time (datetime):
> def __init__(self, hours=0, minutes=0, seconds=0, microseconds=0):
> datetime.__init__(self, 2001, 10, 31, hours, minutes, seconds,
> print time(1,2,3,4) # => 0001-02-03 04:00:00
> print time() # => TypeError: function takes at least 3 arguments (0
> What happens to the default arguments to time.__init__? What happens to the
> 2001, 10, 31 arguments to datetime.__init__?
> I would expect the output to be
> 2001-10-31 01:02:03.000004
> 2001-10-31 00:00:00.000000
More information about the Python-list