Check string “None” or “not” in Python 2.7
For empty strings both are different: will not print anything because it is empty and therefore considered False but: will print because foo is not None! I Changed it according to PEP8. if foo is not None is equivalent to your if not foo is None but more readable and therefore recommended by PEP8. A bit more about the general principles in Python: The if will only be True if a … Read more