__cmp__ between dissimilar objects

Gabriel Genellina gagsl-py at yahoo.com.ar
Tue Nov 14 14:37:56 EST 2006


At Tuesday 14/11/2006 09:33, Fredrik Lundh wrote:

> >>>> GeneralizedTime() > datetime.now()
> > Traceback (most recent call last):
> >  File "<stdin>", line 1, in ?
> > TypeError: can't compare datetime.datetime to GeneralizedTime
> >
> > Clearly I'm misunderstanding something, here.  As I understand my code,
> > I'm directly comparing an instance of datetime (self.datetime) to
> > another instance of datetime.
>
>sure looks like you're comparing a datetime instance against a GeneralizeTime
>instance to me.
>
>why not just inherit from datetime instead?  or read footnote 4 
>under "supported
>operations" on this page for info on how to implement mixed-type comparisions:
>
>     http://docs.python.org/lib/datetime-datetime.html

Ugh... I hope there were good reasons for doing things so convoluted...


-- 
Gabriel Genellina
Softlab SRL 

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar



More information about the Python-list mailing list