Re: checking if a list is empty



On May 5, 11:36 pm, Jabba Laci <jabba.l...@xxxxxxxxx> wrote:
Hi,

If I want to check if a list is empty, which is the more pythonic way?

li = []

(1) if len(li) == 0:
...
or
(2) if not li:

The Python core developers use the second form.
See http://www.python.org/dev/peps/pep-0008/
for the official recommendation.


Raymond

.