Franck Pommereau <[email protected]> added the comment:
I have the problem still exists in 3.4.3 at least:
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import token
>>> token.COMMENT
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'COMMENT'
About the use case: I often use tokenize to build recursive descendant parsers
for domain-specific languages. Not having all the token constants can be worked
around with code below, but it would be so better to have a complete module...
:)
import token
_tok = next(tokenize.tokenize(io.BytesIO(b"").readline))
token.tok_name[_tok.type] = "BACKQUOTE"
for number, name in token.tok_name.items() :
if not hasattr(token, name) :
setattr(token, name, number)
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue31726>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com