by TazeTSchnitzel · 13y ago · 0 comments
[].length is what you want for the second. IIRC [] isn't false in Python either.
>>> if (): print "tuple"
>>> if []: print "list"
>>> if {}: print "dict"
>>> if set(): print "set"
>>> if "": print "string"
>>> import collections
>>> if collections.Counter(): print "counter"
>>> if collections.deque(): print "deque"
>>>
(Observe that none of these prints anything.)