Mega Code Archive

 
Categories / Python / Data Type
 

Anything with a non-zero length is true, empty sequences are false

if []:    print "empty."    if [1]:    print "not empty."    if ():    print "empty."    if (1):    print "not empty." if {}:    print "empty."    if {1:0}:    print "not empty."