What way is the best to check an empty list?
sjmachin at lexicon.net
Wed Mar 25 15:55:10 CET 2009
On Mar 26, 1:38 am, srinivasan srinivas <sri_anna... at yahoo.co.in>
Depends on what you mean by "best"; like graduation day at
kindergarten, everyone gets a prize:
> For ex: to check list 'A' is empty or not..
> if A == :
most obviously correct
> if A.count == 0:
best use of imagination
> if len(A) == 0:
best use of a built-in function
> if not A:
most Pythonic, most laconic, fastest
More information about the Python-list