Re: Pythonic emptiness checking

2009-04-29 Thread MRAB
Carl Banks wrote: On Apr 29, 6:46 am, Bruno Desthuilliers wrote: Filip Gruszczyński a écrit : One of the Python Zen rules is Explicit is better implicit. And yet it's ok to do: if x: do_sth when x is string or list. Since it's very comfy, I've got nothing against though. I am just curious,

Re: Pythonic emptiness checking

2009-04-29 Thread Carl Banks
On Apr 29, 6:46 am, Bruno Desthuilliers wrote: > Filip Gruszczyński a écrit : > > > One of the Python Zen rules is Explicit is better implicit. And yet > > it's ok to do: > > > if x: > >    do_sth > > > when x is string or list. Since it's very comfy, I've got nothing > > against though. I am just

Re: Pythonic emptiness checking

2009-04-29 Thread r
On Apr 29, 8:37 am, Filip Gruszczyński wrote: > One of the Python Zen rules is Explicit is better implicit. And yet > it's ok to do: > > if x: >    do_sth > > when x is string or list. Since it's very comfy, I've got nothing > against though. I am just curious, why is it so? It also works for num

Re: Pythonic emptiness checking

2009-04-29 Thread Filip Gruszczyński
Yes, I get the difference. If x is [], than if x: won't be executed and if x is not None: will be. Thanks for clarifying. -- Filip Gruszczyński -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic emptiness checking

2009-04-29 Thread Sibylle Koczian
Filip Gruszczyński schrieb: > One of the Python Zen rules is Explicit is better implicit. And yet > it's ok to do: > > if x: >do_sth > > when x is string or list. Since it's very comfy, I've got nothing > against though. I am just curious, why is it so? > > And one more thing: is it ok to do

Re: Pythonic emptiness checking

2009-04-29 Thread Bruno Desthuilliers
Filip Gruszczyński a écrit : One of the Python Zen rules is Explicit is better implicit. And yet it's ok to do: if x: do_sth when x is string or list. Since it's very comfy, I've got nothing against though. I am just curious, why is it so? Because it is explicit (or at least considered as

Pythonic emptiness checking

2009-04-29 Thread Filip Gruszczyński
One of the Python Zen rules is Explicit is better implicit. And yet it's ok to do: if x: do_sth when x is string or list. Since it's very comfy, I've got nothing against though. I am just curious, why is it so? And one more thing: is it ok to do if x: instead of if x is not None: Because