[Python-ideas] Non-boolean return from contains (original) (raw)

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon Jul 26 18:23:21 CEST 2010


On Mon, Jul 26, 2010 at 12:09 PM, Ian Bicking <ianb at colorstudy.com> wrote: ..

I know overriding "and" and "or" has been discussed some time ago, though I'm not sure what the exact reason is that it never went anywhere.

Indeed. See PEP 335. http://www.python.org/dev/peps/pep-0335/.

I remember it as one of those epic-and-boring comp.lang.python threads ;)  One obvious complication is that they are short-circuit operations.  That is, "a and b" must evaluate a, figure out if it is false, and if so then it returns a.  But "a or b" must evaluate a, figure out if it is TRUE, and if so then returns a.  So if there was anything like and and or it would have to simply disable any short-circuiting.

The PEP deals with short-circuiting AFAIK.



More information about the Python-ideas mailing list