On Fri, 06 Mar 2009 15:34:08 -0000, Grant Edwards <inva...@invalid> wrote:
On 2009-03-06, Fencer <no.s...@plz.ok> wrote:
Hi, I need a boolean b to be true if the variable n is not
None and not an empty list, otherwise b should be false.
I ended up with:
b = n is not None and not not n
I'd do it like this:
b = (n is not None) and (n != [])
The second comparison isn't actually necessary, since an
empty list is True and a non-empty one False.
b = (n is not None) and n
Putting the comparison in does make the code slightly less
"magic", though, so it's not a bad idea to do it!
--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list