and [True,True] --> [True, True]?????

"Martin v. Löwis" martin at
Mon Apr 20 22:05:57 CEST 2009

> Are they widespread? I haven't noticed, yet.
> I prefer to write it explicitly:
> if len(lst) > 0:

I prefer to test explicitly for the truth value of the
list. I don't want to test whether the length of the list
is greater than 0 (in fact, I don't care about the length
property of the list at all) - I want to know whether the
list is empty (or not empty). The Python syntax for this
test is

if lst:
  # not empty


if not list:

The view "let me test for the precise value" leads to
formulations like

if foo is True:
   return True
   return False

People should have more trust in boolean conversions.


More information about the Python-list mailing list