4

I came across the question Python: What is the best way to check if a list is empty? on SO.

Now if I wanted to return a True (False) depending on whether a collection coll is non-empty (empty) from a function, what's the recommended way of doing this ? return not not coll ?

Community
  • 1
  • 1
Andre Holzner
  • 18,333
  • 6
  • 54
  • 63

1 Answers1

11

You could use

return bool(coll)
Steef
  • 33,059
  • 4
  • 45
  • 36