[Python-ideas] Please reconsider the Boolean evaluation of midnight
Stephen J. Turnbull
stephen at xemacs.org
Thu Mar 6 09:34:06 CET 2014
Yann Kaiser writes:
> if event.date:
> schedule_event()
>
> I cannot fathom one example where it could read as "does the party
> start at midnight?". Can you?
No, because it obviously reads as "... WTF??!?"[1]
Of course, that's because I've imbibed of the "Python is not C or C++"
Kool-Aid, but I just don't see why we should encourage C idioms in
Python when there are plenty of other cases where use of a bare
expression rather "... is None" can bite.
I find Skip Montanaro's implied issue
Please reconsider the Boolean evaluation of None
far more plausible.<wink/>
Footnotes:
[1] if event.date: print("Happy New Year/Century/Millennium!")
More information about the Python-ideas
mailing list