PEP 285: Adding a bool type

John Roth johnroth at ameritech.net
Mon Apr 1 19:33:25 EST 2002


"Erik Max Francis" <max at alcyone.com> wrote in message
news:3CA8B4CC.88C35BB0 at alcyone.com...
> Stefan Schwarzer wrote:
>
>
> I don't see why you think the behavior (I presume you're referring to
> syntaxes like True == 2) is counterintuitive.  Why _would_ you expect
> this to do what you want?  It doesn't for any other Python types that
> I'm aware of.  == tests for equality, it doesn't do automatic type
> coercion.

Actually, "==" does whatever the class wants, if the class
has defined the appropriate magic method. Of course,
if you want other ordering functions to work that depend on
the "==" operator, then the class designer has to be reasonable
about what he has it do, but he doesn't have to.

And yes, he can include automatic type coercions if he wants to.

John Roth

>
> --
>  Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
>  __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
> /  \ Nationalism is an infantile sickness.
> \__/ Albert Einstein
>     Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html
>  A new, virtual planet, every day.





More information about the Python-list mailing list