summaryrefslogtreecommitdiffstats
path: root/Lib/tokenize.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-09-09 08:29:05 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-09-09 08:29:05 (GMT)
commita0e79408bcf14015995fb4f1f1c3ad88df017496 (patch)
tree258a73fce0ea19210766de620f99ee274c3f708f /Lib/tokenize.py
parent3fb79c747b0cd0884f2a6ede9e36673bec8745f2 (diff)
downloadcpython-a0e79408bcf14015995fb4f1f1c3ad88df017496.zip
cpython-a0e79408bcf14015995fb4f1f1c3ad88df017496.tar.gz
cpython-a0e79408bcf14015995fb4f1f1c3ad88df017496.tar.bz2
A little bit more readable repr method.
Diffstat (limited to 'Lib/tokenize.py')
-rw-r--r--Lib/tokenize.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/tokenize.py b/Lib/tokenize.py
index cd3c93d..eb58831 100644
--- a/Lib/tokenize.py
+++ b/Lib/tokenize.py
@@ -47,9 +47,9 @@ N_TOKENS += 3
class TokenInfo(collections.namedtuple('TokenInfo', 'type string start end line')):
def __repr__(self):
- typ = self.type
- return 'TokenInfo(type=%s, string=%r, start=%r, end=%r, line=%r)' % \
- ((('%d (%s)' % (typ, tok_name[typ])),) + self[1:])
+ annotated_type = '%d (%s)' % (self.type, tok_name[self.type])
+ return ('TokenInfo(type=%s, string=%r, start=%r, end=%r, line=%r)' %
+ self._replace(type=annotated_type))
def group(*choices): return '(' + '|'.join(choices) + ')'
def any(*choices): return group(*choices) + '*'