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

Ethan Furman ethan at stoneleaf.us
Fri Mar 7 05:47:26 CET 2014


On 03/06/2014 09:40 AM, Stephen J. Turnbull wrote:
> Antoine Pitrou writes:
>   > Le 06/03/2014 15:33, Stephen J. Turnbull a écrit :
>
>   > > never get fixed, and that "if var:" which is actually testing for
>   > > identity with a false-y sentinel is still strongly discouraged.
>   >
>   > Why "strongly discouraged"? This is more of a style issue than anything
>   > else?
>
> No, it's not just a style issue.  As Skip points out, it's a
> *semantic* issue as well.

Indeed, I have been bitten by using the lazy method of `if var` instead of `if var is not None`, and then been briefly 
puzzled as why my empty string | container | whatever that I passed in did not give me the correct results.

I'm still all for having truthy midnights.  :)

--
~Ethan~


More information about the Python-ideas mailing list