if does not evaluate

Matteo Dell'Amico della at toglimi.linux.it
Sun Jun 6 04:17:23 EDT 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
> 2.3.3.

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.

-- 
Ciao,
Matteo



More information about the Python-list mailing list