Martin Häcker [EMAIL PROTECTED] wrote:
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?
Its a bug!
Nick Craig-Wood wrote:
Martin Häcker [EMAIL PROTECTED] wrote:
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. :(
Its a bug!
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?
Thanks a bunch.
--- snip ---
import unittest
from datetime import datetime
class time (datetime):
def __init__(self, hours=0, minutes=0, seconds=0,
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?
Thanks a bunch.
--- snip ---
import unittest
from datetime import datetime
class time (datetime):
def __init__(self, hours=0,
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,
Hi,
It looks like the assertEquals use the != operator which had not been defined
to compare instances of your time class and instances of the datetime class.
In such a case, the operator ends up in comparing the references to instances,
i.e. the id of the objects, i.e. their physical memory
Wow !
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.
Francis Girard
Le jeudi 20 Janvier 2005 19:59, Kent Johnson a écrit :
Martin Häcker wrote:
Hi there,
I just tried to run this code
Kent Johnson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
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:
Paul McGuire wrote:
Kent Johnson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
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
Ah, right. The light turns on...
datetime is immutable so overriding the constructor doesn't change the
constructed object. You have to override __new__ instead.
http://www.python.org/2.2.1/descrintro.html#__new__
Ahhh! Thanks a bunch, now this makes things much clearer.
Thanks again!
cu Martin
10 matches
Mail list logo