Overriding logical operators?
Terry Reedy
tjreedy at udel.edu
Sat Aug 21 03:35:25 EDT 2004
"Andrew Durdin" <adurdin at gmail.com> wrote in message
news:59e9fd3a04082022392b749256 at mail.gmail.com...
> I noticed that, although there are special methods for most operators,
> they are conspicuously absent for the logical "or" and "and". I'm
> guessing that the reason for this is that these operators
> short-circuit if their first operand answers the whole question?
If you think of a op b as being an alternate, abbreviated syntax for the
function call op(a,b), then short-circuiting 'and' and 'or' are not really
operators. Various Lisp dialects have various terms, such as 'special
form' for syntax that looks like a normal function call but isn't. I think
we need a special term in Python also, such as 'pseudo-op' or 'syntax
operator' to flag 'and' and 'or' as importantly different from regular
operators.
Terry J. Reedy
More information about the Python-list
mailing list