automatic type conversion for comparison operators

Russ uymqlp502 at sneakemail.com
Thu Jul 26 21:04:47 EDT 2007


Dan Bishop wrote:

> BTW, are you a former Pascal programmer?

No. Why do you ask? [The code snippet I wrote was made up to get a
point across. I
did not actually use that function name in my code.]

> > But Python
> > somehow compares the function pointer with an integer without
> > complaining. Unless there is a darn good reason for allowing
> > comparisons of this type (and I can't think of one), I think
> > Python should flag this as an Exception.
>
> IIRC, the reason is for backwards compatibility with a long-obsolete
> version of Python in which it wasn't possible for __cmp__ to throw an
> exception.  That's not darn good, so this behavior is already slated
> for removal in version 3.0.

That's good to know. Thanks.




More information about the Python-list mailing list