David Ascher wrote: > > Guido van Rossum wrote: > > > > > > Despite the negative feedback, I've decided to accept the PEP. The > > > > most important perceived problem is that newbies tend to write > > > > > > > > if x == True: ... > > > > > > > > where they should write > > > > > > > > if x: ... > > > > > > > > I believe this problem should be solved by education (the Zen master > > > > hits the student on the head with a stick, and the student gets > > > > enlightenment) rather than by holding back what I believe will be a > > > > useful feature. > > > > > > Would it not be "relatively" easy to add a compiler-time warning for > > > most uses of this dangerous idiom? > > > > I think this would be a job for PyChecker. Neal? > > Neal just posted that PyChecker deals with it, which is great, but I > don't think that PyChecker is enough - until PyChecker is part of the > standard distribution and integrated with e.g. the interactive shell, I > think that PyChecker is not likely to be used by novices. And we're > talking about novices here, right? > > Come to think of it, getting PyChecker integrated w/ the interactive > shell would be great! Hard, I suspect, but great! Not too hard: >>> from pychecker import checker >>> import test_bool test_bool.py:6: Comparisions with True are not necessary test_bool.py:7: Comparisions with False are not necessary If you always wanted this, you could add a PYTHONSTARTUP script to do the import or you could add/modify sitecustomize.py. It probably isn't perfect since I don't use this, but it could work. Neal
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4