Readability counts, was Re: Use of Lists, Tupples, or Sets in IF statement.

Rustom Mody rustompmody at gmail.com
Tue Mar 15 22:54:49 EDT 2016


On Tuesday, March 15, 2016 at 11:05:32 PM UTC+5:30, Peter Otten wrote:
> Indeed. It's still better than
> 
> "This is %s a fruit" % (x in x_list and "" or "not")
> 
> The bug is intentional; the fix is of course
> 
> "This is %s a fruit" % (x in x_list and "most likely" or "probably not")
> 
> ;)

Thanks
I wondered what/why you were bringing in this clunky, error-prone
pre-conditional meme...
And came across https://mail.python.org/pipermail/python-dev/2005-September/056510.html

| I propose that in Py3.0, the "and" and "or" operators be simplified to
| always return a Boolean value instead of returning the last evaluated
| argument.

Good to know that Raymond Hettinger disagrees with Guido on the
messed-up, ½-class status of bools in python



More information about the Python-list mailing list