Python> these are all considered False:

@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 2045 / 12833)

A false value doesn't necessarily need to explicitly be False. For example, these are all considered False:

boolean False
null None
zero integer 0
zero float 0.0
empty string ''
empty list []
empty tuple ()
empty dict {}
empty set set()

Anything else is considered True.

I've tried.

http://ideone.com/fTS6kQ

def check_empty(something):
	if something:
		print('Not Empty')
	else:
		print('Is Empty')
	
alist = []
check_empty(alist)
alist.append('7of9')
check_empty(alist)

aint = 0
check_empty(aint)
aint = 314
check_empty(alist)

result


Success	time: 0 memory: 23304 signal:0
Is Empty
Not Empty
Is Empty
Not Empty

Recommended Posts

Python> these are all considered False:
All Python arguments are passed by reference
What are python tuples and * args after all?
Python classes are slow
About __all__ in python
Make sure all the elements in the list are the same in Python