[Python-projects] feature request: detecting when it's safe to ignore builtin overrides
skip at pobox.com
skip at pobox.com
Mon Nov 24 16:06:28 CET 2008
SpamBayes tries to work on versions of Python as old as 2.2. Accordingly,
we put code in to make sure some potentially missing symbols are checked and
set if necessary:
try:
True, False
except NameError:
# Maintain compatibility with Python 2.2
True, False = 1, 0
If I pylint this code using a version of Python which does support True &
False (actually, Python 2.2 acquired those symbols sometime during the 2.2
lifetime) it complains about overriding True and False. It would be nice if
pylint could detect this sort of construct. 'try' something. If there is
an 'except NameError' clause, pretend for the duration of that clause that
any builtin symbols referenced in the try clause really don't exist (even
though they might well exist in the version of Python being run) so that the
statements in the except clause don't trigger complaints about the override.
Thanks,
--
Skip Montanaro - skip at pobox.com - http://smontanaro.dyndns.org/
More information about the Python-Projects
mailing list