No, None
is only the same thing as None
itself. Empty strings are not the same thing:
>>> None == ""
False
None
is a special singleton value (there is only one copy of it in a Python session) signifying 'emptyness', or the lack of a 'proper' value. As such it is a flag or signal value; Python uses it by convention to signal that a process didn't return anything, for example.
Both None
and the empty string are considered false in a boolean context:
>>> bool(None)
False
>>> bool("")
False
as are all empty containers (such as an empty tuple, list or set) and numeric 0 (be it integer, floating point or a complex number). Being considered false doesn't make them equal, however.
If you wanted to test for any value that is false, use:
while not variable:
as not
interprets the operand in a boolean context and returns the inverse value:
>>> not ""
True
>>> not None
True
>>> not "not empty"
False