What way is the best to check an empty list?

Raymond Hettinger python at rcn.com
Wed Mar 25 15:58:11 EDT 2009


On Mar 25, 7:38 am, srinivasan srinivas <sri_anna... at yahoo.co.in>
wrote:
> For ex: to check list 'A' is empty or not..
> if A == []:
> if A.count == 0:
> if len(A) == 0:
> if not A:

PEP 8 recommends the latter.


Raymond



More information about the Python-list mailing list