Re: __cmp__ between dissimilar objects

2006-11-14 Thread Gabriel Genellina
At Tuesday 14/11/2006 19:27, [EMAIL PROTECTED] wrote: > >Can you point me to a description of this algorithm? It doesn't seem > >to be described in the documentation for the rich comparison or __cmp__ > >methods... > > PEP 207 > http://www.python.org/dev/peps/pep-0207/ So since I implemented _

Re: __cmp__ between dissimilar objects

2006-11-14 Thread [EMAIL PROTECTED]
> >Can you point me to a description of this algorithm? It doesn't seem > >to be described in the documentation for the rich comparison or __cmp__ > >methods... > > PEP 207 > http://www.python.org/dev/peps/pep-0207/ So since I implemented __cmp__ instead of the rich comparison operators, Python f

Re: __cmp__ between dissimilar objects

2006-11-14 Thread Gabriel Genellina
At Tuesday 14/11/2006 09:33, Fredrik Lundh wrote: GeneralizedTime() > datetime.now() > Traceback (most recent call last): > File "", line 1, in ? > TypeError: can't compare datetime.datetime to GeneralizedTime > > Clearly I'm misunderstanding something, here. As I understand my code, > I'

Re: __cmp__ between dissimilar objects

2006-11-14 Thread Gabriel Genellina
At Tuesday 14/11/2006 13:41, [EMAIL PROTECTED] wrote: > When the rich comparison methods raise NotImplementedError, the > comparison logic inside the interpreter tries reversing the operands. Can you point me to a description of this algorithm? It doesn't seem to be described in the documentat

Re: __cmp__ between dissimilar objects

2006-11-14 Thread [EMAIL PROTECTED]
> why not just inherit from datetime instead? I'll probably do that in the next iteration. > 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 OK. I added a 'timetuple

Re: __cmp__ between dissimilar objects

2006-11-14 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: >I have a class that has, as an attribute, an instance of > datetime.datetime(). I would like to be able to compare my class > directly to instances of datetime.datetime in addition to other > instances of my class. The value used for the comparison in either > case shou

Re: __cmp__ between dissimilar objects

2006-11-14 Thread [EMAIL PROTECTED]
> When the rich comparison methods raise NotImplementedError, the > comparison logic inside the interpreter tries reversing the operands. Can you point me to a description of this algorithm? It doesn't seem to be described in the documentation for the rich comparison or __cmp__ methods... -Ben

Re: __cmp__ between dissimilar objects

2006-11-13 Thread Gabriel Genellina
At Monday 13/11/2006 21:33, [EMAIL PROTECTED] wrote: I have a class that has, as an attribute, an instance of datetime.datetime(). I would like to be able to compare my class directly to instances of datetime.datetime in addition to other instances of my class. The value used for the compariso