On Sun, Apr 17, 2016 at 12:24 PM, Pavol Lisy <pavol.l...@gmail.com> wrote: > 2016-04-09 17:43 GMT+02:00, Steven D'Aprano <st...@pearwood.info>: >> flag ^ flag is useful since we don't have a boolean-xor operator and >> bitwise-xor does the right thing for bools. And I suppose some people >> might prefer & and | over boolean-and and boolean-or because they're >> shorter and require less typing. I don't think that's a particularly >> good reason for using them, and as you say, you do have to guard >> against non-bools slipping, but Consenting Adults applies. > > They are also useful if you need to avoid short-circuit evaluation.
One can easily write functions to do that. def long_or(a, b): """Equivalent to a or b but always evaluates both expressions.""" return a or b long_or(a, b) may not be as pretty as a | b, but I'll argue that it's more readable since it's up-front about its intent, whereas a | b looks like it could just be a mistake. -- https://mail.python.org/mailman/listinfo/python-list