Message303911
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) |
|
Date |
User |
Action |
Args |
2017-10-08 15:46:01 | fpom | set | recipients:
+ fpom, r.david.murray |
2017-10-08 15:46:01 | fpom | set | messageid: <1507477561.47.0.213398074469.issue31726@psf.upfronthosting.co.za> |
2017-10-08 15:46:01 | fpom | link | issue31726 messages |
2017-10-08 15:46:01 | fpom | create | |
|