git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

``if var'' and ``if var is not None''


On 2019-09-01 8:12 AM, Hongyi Zhao wrote:
> Hi,
> 
> The following two forms are always equivalent:
> 
> ``if var'' and ``if var is not None''
> 
> Regards
> 

Not so. Here is an example -

 >>> var = []
 >>> bool(var)
False
 >>> bool(var is not None)
True
 >>>

Frank Millman