I have an existing application that connects to a database. It works under Python 2.7.
The application is incompatible with the way it uses None and "" to populate variables that do not matter. I want to make this consistent and try to update the code anyway.
Thinking as a database person, I think of None as the same as Null, and would suggest that it would be the right choice for empty variables, but then it causes problems when the application does things like
if variable.upper() == "X":
Since this causes an error if the variable is of type None.
I can do
if variable is not None and variable.upper() == "X":
But that seems overly detailed.
Is there any best practice for how this needs to be handled?
source share