default arguments newbie question

Erik Max Francis max at alcyone.com
Thu Jan 11 13:38:58 EST 2001


Moshe Zadka wrote:

> But not for user-defined objects:
> 
> class FoolErik:
> 
>         def __cmp__(self, other):
>                 return cmp(None, other)

Sure, you can come up with pathological cases.  Are there really serious
cases where something like this would be done?  More importantly -- is
there a case where someone would do such a thing (having a user-defined
object which compared equal to None) that would do the wrong thing in
the code example?  If it compares equal to None, shouldn't surrounding
code act like it _was_ None?  If not, what is the point of having
something which compares equal to None but is not None?  Why would one
make such a distinction?

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Divorces are made in Heaven.
\__/ Oscar Wilde
    Crank Dot Net / http://www.crank.net/
 Cranks, crackpots, kooks, & loons on the Net.



More information about the Python-list mailing list