None
is the sole instance of the NoneType
and is usually used to signify absence of value. What happens in your example is that the empty list, taken in boolean context, evaluates to False
, the condition fails, so the else branch gets executed. The interpreter does something along the lines of:
>>> a if a else None
[] if [] else None
[] if False else None
None
Here is another useful discussion regarding None
: not None test in Python