Isn't bool __invert__ behaviour "strange"?

Saizan sanzhiyan at gmail.com
Fri Sep 22 11:25:55 EDT 2006


Bjoern Schliessmann wrote:
> Saizan wrote:
>
> > Why subclassing bool from int either __invert__ or __neg__ haven't
> > been overrided to produce a boolean negation?
>
> I wonder what -True or -False should evaluate to.
>
> Regards,
>
>
> Björn
>
> --
> BOFH excuse #297:
>
> Too many interrupts
Well in boolean notation -True == False and  -False == True, actually
you may prefer ¬ or a line over the term, but since there's no such
operator in python I think we should use "-" which is also the operator
used by Bool himself in his formulation for negation which was 1-x.
Now that I think of it 1-x should work as a negation in Python, too,
since True == 1 and False == 0, but it would be a little annoying to
write expressions in this way.




More information about the Python-list mailing list