Comment on PEP-0238
Guido van Rossum
guido at python.org
Fri Jul 6 15:37:43 EDT 2001
"Edward C. Jones" <edcjones at erols.com> writes:
> I suggest including a program that will read Python code and tell
> the user where all the "/" divisions are in the code.
That's easy enough:
import sys, tokenize
for filename in sys.argv[1:]:
def tokeneater(type, token, start, end, line, filename=filename):
if token == "/": print "%s:%d:%s" % (filename, start[0], line),
tokenize.tokenize(open(filename).readline, tokeneater)
Unfortunately, this doesn't tell you which / operators are ever
applied to *integer* arguments -- no program looking only at the
source can determine that. That's what the warnings are for.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-list
mailing list