[Python-Dev] the not operator (and the __not__ special method)
Guido van Rossum
guido@python.org
Thu, 03 Oct 2002 20:19:43 -0400
> [...] I guess it will be also good to have the special methods for
> the logical operations 'and', 'or' and 'not', (something like
> __land__, __lor__ and __lnot__ to distinguish them from the bitwise
> versions __and__ and __or__).
>
> So, if you overload the proper logical methods, you can write
> something like
>
> cond = not (sin(x) > 0.5 ) and ( b <= 0.5 )
>
> where 'not' and 'and', like '>' and '<=', wil return anything you want.
Sorry, that won't be possible any time soon. If I allowed these
operators to be overloaded, they would lose their shortcut properties,
which are the reason for their existence.
--Guido van Rossum (home page: http://www.python.org/~guido/)