You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
423 B
31 lines
423 B
11 years ago
|
# Test true-ish value handling
|
||
|
|
||
|
if not False:
|
||
|
print("False")
|
||
|
|
||
11 years ago
|
if not None:
|
||
|
print("None")
|
||
|
|
||
11 years ago
|
if not 0:
|
||
|
print("0")
|
||
|
|
||
|
if not "":
|
||
|
print("Empty string")
|
||
|
if "foo":
|
||
|
print("Non-empty string")
|
||
|
|
||
|
if not ():
|
||
|
print("Empty tuple")
|
||
|
if ("",):
|
||
|
print("Non-empty tuple")
|
||
|
|
||
|
if not []:
|
||
|
print("Empty list")
|
||
|
if [0]:
|
||
|
print("Non-empty list")
|
||
|
|
||
|
if not {}:
|
||
|
print("Empty dict")
|
||
|
if {0:0}:
|
||
|
print("Non-empty dict")
|