True inconsistency in Python
Alex Martelli
aleax at aleax.it
Thu Nov 13 10:38:26 EST 2003
Scott Chapman wrote:
...
> It seems that maybe Python should throw a warning (perhaps if a flag is
> set) any time it bumps into code comparing a variable to True or False.
It's a bit hard to do it just for variables, but doing it for _any_
comparison would _almost_ be reasonable -- testing if something
"== True" is hardly ever sensible. Unfortunately "a == b" CAN
be perfectly sensible and either or both of the variables MIGHT
just happen to be set to True.
However, this looks to me like a good suggestion for PyChecker
and the like, which should be able to catch and flag the actual
explicit use or the constant True in code involving == or != ...
Alex
More information about the Python-list
mailing list