The question I'm about to ask here has been asked before, but those questions/answers make no mention of what I want to know.
I recall a few months or so ago, I had a rather sizable Python script, and I was using if x:
because it was shorter and I was lazy. I don't remember which version of Python, but I do remember getting a DeprecationWarning
(or PendingDeprecationWarning
?) about implicit comparisons to True
.
Now, I'm trying to write something someone else might read. I'm using if x == True
and if x is not None
everywhere, and pep8
and pylint
are complaining about this, saying I should use if x:
.
Personally, I think if x:
is far less readable, but pep8
(the program) and PEP 8 (the document) both disagree.
Google is not being very helpful in allowing me to figure in which version, if ever, Python gave a DeprecationWarning
for if x:
, so I wonder if perhaps the SO community can provide insight.
Should I be worrying about this at all? Does it actually matter that much?