bool behavior in Python 3000?
Bruno Desthuilliers
bruno.42.desthuilliers at wtf.websiteburo.oops.com
Wed Jul 11 10:37:19 EDT 2007
Steven Bethard a écrit :
(snip)
> Remember that while Python 3 is allowed to break backwards
> compatibility, it's only supposed to do it when there are concrete
> benefits. Clearly there are existing use cases for treating bools like
> ints, e.g. from Alexander Schmolck's email:
>
> (x < b) * f(x)
> -1 ** (i == j)
Both can be cleanly handled using int():
int(x < b) * f(x)
-1 ** int(i == j)
Not that I have any clear opinion on the topic FWIW.
More information about the Python-list
mailing list