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

Antoine Pitrou solipsis at pitrou.net
Thu Mar 6 12:09:12 CET 2014


Le 06/03/2014 12:04, M.-A. Lemburg a écrit :
>
> Writing
>
>      if x: print ('x is None')
>
> or
>
>      if x == None: print ('x is None')
>
> is wrong code.

No it isn't.

> None is a singleton, so you have to use the "is" operator, i.e.
>
>      if x is None: print ('x is None')
>
> is the only correct way of testing for None.

No it isn't.  x == None is a perfectly well-defined way of doing it, 
even if it isn't the stylistically preferred one.

Regards

Antoine.




More information about the Python-ideas mailing list