]> granicus.if.org Git - python/commitdiff
A little bit more readable repr method.
authorRaymond Hettinger <python@rcn.com>
Thu, 9 Sep 2010 08:29:05 +0000 (08:29 +0000)
committerRaymond Hettinger <python@rcn.com>
Thu, 9 Sep 2010 08:29:05 +0000 (08:29 +0000)
Lib/tokenize.py

index cd3c93d7a3f8956187207eac213883576b98e776..eb58831cced338e829a0c3fd5b1fd5ccae91c261 100644 (file)
@@ -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) + '*'