How to check if a variable is empty in python?
python
Solution
Yes, `bool`. It's not exactly the same -- `'0'` is `True`, but `None`, `False`, `[]`, `0`, `0.0`, and `""` are all `False`.
`bool` is used implicitly when you evaluate an object in a condition like an `if` or `while` statement, conditional expression, or with a boolean operator.
If you wanted to handle strings containing numbers as PHP does, you could do something like:
def empty(value):
try:
value = float(value)
except ValueError:
pass
return bool(value)
Problem
I am wondering if python has any function such as php empty function (http://php.net/manual/en/function.empty.php) which check if the variable is empty with following criteria ``` "" (an empty string) 0 (0 as an integer) 0.0 (0 as a float) "0" (0 as a string) NULL FALSE array() (an empty array) ```