if does not evaluate
della at toglimi.linux.it
Sun Jun 6 10:17:23 CEST 2004
Tor Iver Wilhelmsen wrote:
> x = (expr1, expr2)[something];
> Keep in mind that this might break on some later release of Python if
> they decide to make boolean its own type, but at least it works for
I think (and I hope) it will never be so, since bool is already its own
type and, as the documentation states,
"In numeric contexts (for example when used as the argument to an
arithmetic operator), they behave like the integers 0 and 1, respectively."
So, even if this a little "perlish" :-), I think it will continue to
work in future versions of python, since otherwise it would break too
much existing code.
More information about the Python-list