What way is the best to check an empty list?
John Machin
sjmachin at lexicon.net
Wed Mar 25 10:55:10 EDT 2009
On Mar 26, 1:38 am, srinivasan srinivas <sri_anna... at yahoo.co.in>
wrote:
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
mailing list