SyntaxError not honoured in list comprehension?
jmfauth
wxjmfauth at gmail.com
Mon Jul 5 14:12:19 EDT 2010
Thank you all for the discussion and the explanations.
> Mark Dickinson
I toyed a littled bit this afternoon and I wrote a colouriser
(British spelling?) with the tokenize module. It is quite
simple and easy.
BTW, if I understand correctly the module tokenize import
the module token. So your example becomes:
>>> from cStringIO import StringIO
>>> import tokenize
>>> for tok in tokenize.generate_tokens(StringIO("print9.0").readline):
print tokenize.tok_name[tok[0]], tok[1]
NAME print9
NUMBER .0
ENDMARKER
>>>
More information about the Python-list
mailing list