Re: Overloading ctor doesn't work?

2005-01-21 Thread Nick Craig-Wood
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!

Re: Overloading ctor doesn't work?

2005-01-21 Thread Kent Johnson
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!

Overloading ctor doesn't work?

2005-01-20 Thread Martin Häcker
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,

Re: Overloading ctor doesn't work?

2005-01-20 Thread Steve Holden
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,

Re: Overloading ctor doesn't work?

2005-01-20 Thread Kent Johnson
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,

Re: Overloading ctor doesn't work?

2005-01-20 Thread Francis Girard
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

Re: Overloading ctor doesn't work?

2005-01-20 Thread Francis Girard
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

Re: Overloading ctor doesn't work?

2005-01-20 Thread Paul McGuire
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:

Re: Overloading ctor doesn't work?

2005-01-20 Thread Kent Johnson
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

Re: Overloading ctor doesn't work?

2005-01-20 Thread Martin Häcker
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