[Python-ideas] Please reconsider the Boolean evaluation of midnight

Shai Berger shai at platonix.com
Wed Mar 5 18:24:04 CET 2014


On Wednesday 05 March 2014 19:09:11 Skip Montanaro wrote:
> On Wed, Mar 5, 2014 at 9:15 AM, Shai Berger <shai at platonix.com> wrote:
> > Also, when opening this thread, I argued that 0 is special,
> > but midnight is not -- which you completely ignore.
> 
> Zero is not different, at least when considered as an element of a set
> (of integers, in my example). What's important is that we have a set
> of values (either time objects or integers in these two examples) and
> need some way to specify a sentinel value.

Your argument has merit, but is besides the point. As noted by many in this 
thread, the idiom "if obj:" for deciding on the existence of some value is 
quite common. We all know it doesn't always fit, because Python chose to make 
some objects falsey; however, when it does fit, it makes for succinct, clear, 
unceremonious code.

If your argument is not that "if obj:" should never be used, except when obj 
actually is Boolean, please elaborate.

At issue here is the fact that the idiom doesn't fit where one would expect 
that it should.

Thanks,
	Shai.



More information about the Python-ideas mailing list