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

2019-09-01 Thread Ian Kelly
On Sun, Sep 1, 2019, 8:58 AM Terry Reedy wrote: > On 9/1/2019 2:12 AM, Hongyi Zhao wrote: > > > The following two forms are always equivalent: > > ``if var'' and ``if var is not None'' > > Aside from the fact that this is false, why would you post suc

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

2019-09-01 Thread Terry Reedy
On 9/1/2019 2:12 AM, Hongyi Zhao wrote: The following two forms are always equivalent: ``if var'' and ``if var is not None'' Aside from the fact that this is false, why would you post such a thing? Trolling? Did you hit [Send] prematurely? -- Terry Jan Reedy -- htt

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

2019-09-01 Thread Piet van Oostrum
Hongyi Zhao writes: > Hi, > > The following two forms are always equivalent: > > ``if var'' and ``if var is not None'' > > Regards In [1]: var = 0 In [2]: if var: ...: print('True') ...: else: ...: print('False'

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

2019-08-31 Thread Frank Millman
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 >>

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

2019-08-31 Thread Chris Angelico
On Sun, Sep 1, 2019 at 4:16 PM Hongyi Zhao wrote: > > Hi, > > The following two forms are always equivalent: > > ``if var'' and ``if var is not None'' > Ahh... False. I'll go False. I'll be honest, I might have heard that one

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

2019-08-31 Thread Hongyi Zhao
Hi, The following two forms are always equivalent: ``if var'' and ``if var is not None'' Regards -- https://mail.python.org/mailman/listinfo/python-list