Removing comments... tokenize error
Fredrik Lundh
fredrik at pythonware.com
Tue Apr 12 14:17:13 EDT 2005
"qwweeeit" <qwweeeit at yahoo.it> wrote:
> I don't know if this has already been corrected (I use Python 2.3)
> or perhaps is a mistake on my part...
it's a mistake on your part. adding a print statement to the for-
loop might help you figure it out:
> nLastLine=0
> for i in tokenize.generate_tokens(f.readline):
print i
> . if nLastLine != (i[2])[0]: # the 3rd element of the tuple is
> . . nLastLine = (i[2])[0] # (startingRow, startingCol)
> . . fOut.write(i[4])
(hints: what happens if a token spans multiple lines? and how does
the tokenize module deal with comments?)
</F>
More information about the Python-list
mailing list