The Python Tourist: None, empty, and nothing.

Coming from a C background to Python, I made the assumption that Python's None value was to be used much like a NULL pointer in C. Based on this assumption, I happily coded away using patterns like "if not function()", much like you would say "if !fgets(...)" in C. Only after running into some non-obvious bugs did the wisdom of "always explicitly test for None" become clearer to me.

Issue #4: None, empty and nothing.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

[...] The Python Tourist

[...] The Python Tourist takes a look at Testing for None in Python. It sounds like a simple enough topic, but it’s really an interesting read if you are new to the language. Definitely recommended reading. [...]

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.