From: Raymond Hettinger Date: Thu, 9 Sep 2010 08:29:05 +0000 (+0000) Subject: A little bit more readable repr method. X-Git-Tag: v3.2a3~361 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a0e79408bcf14015995fb4f1f1c3ad88df017496;p=python A little bit more readable repr method. --- diff --git a/Lib/tokenize.py b/Lib/tokenize.py index cd3c93d7a3..eb58831cce 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) + '*'