bool behavior in Python 3000?
bruno.42.desthuilliers at wtf.websiteburo.oops.com
Wed Jul 11 16:37:19 CEST 2007
Steven Bethard a écrit :
> 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