Python What is the best way to check if a list is empty?#stackoverflow · #python · · Peter Hoffmann This my Answer to the stackoverflow question: Python: What is the best way to check if a list is empty?:
An empty list is itself considered false in true value testing (see python documentation):
a =  if a: print "not empty"
EDIT: Another point against testing the empty list as False: What about polymorphism? You shouldn't depend on a list being a list. It should just quack like a duck - how are you going to get your duckCollection to quack ''False'' when it has no elements?
Your duckCollection should implement
__len__ so the if a: will work without problems.