bool behavior in Python 3000?

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Thu Jul 12 03:47:27 CEST 2007


On Wed, 11 Jul 2007 08:04:33 +0200, Stargaming wrote:


> No, I think Bjoern just wanted to point out that all those binary 
> boolean operators already work *perfectly*. You just have to emphasize 
> that you're doing boolean algebra there, using `bool()`.
> "Explicit is better than implicit."


So we should always write things explicitly like:

if bool(bool(some_condition) is True) is True:
    first_line = str(some_string).split(str("\n"))[int(0)]
    n = int(int(len(list(some_list))) + int(1))
elif bool(bool(some_condition) is False) is True:
    f = float(math.sin(float(6.0)/float(math.pi)))

instead of the less explicit code. I'll try to remember that, thank you
for the advice.



-- 
Steven




More information about the Python-list mailing list