checking if a list is empty
- From: Jabba Laci <jabba.laci@xxxxxxxxx>
- Date: Fri, 6 May 2011 02:36:26 -0400
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:
....
Thanks,
Laszlo
.
- Follow-Ups:
- Re: checking if a list is empty
- From: Raymond Hettinger
- Re: checking if a list is empty
- From: scattered
- Re: checking if a list is empty
- From: Richard Thomas
- Re: checking if a list is empty
- Prev by Date: Re: 回复: Re: BeautifulSoup import error
- Next by Date: Re: Python-list Digest, Vol 92, Issue 40
- Previous by thread: Re: 回复: Re: BeautifulSoup import error
- Next by thread: Re: checking if a list is empty
- Index(es):