A little bit more readable repr method.

This commit is contained in:
Raymond Hettinger 2010-09-09 08:29:05 +00:00
parent 3fb79c747b
commit a0e79408bc
1 changed files with 3 additions and 3 deletions

View File

@ -47,9 +47,9 @@ N_TOKENS += 3
class TokenInfo(collections.namedtuple('TokenInfo', 'type string start end line')): class TokenInfo(collections.namedtuple('TokenInfo', 'type string start end line')):
def __repr__(self): def __repr__(self):
typ = self.type annotated_type = '%d (%s)' % (self.type, tok_name[self.type])
return 'TokenInfo(type=%s, string=%r, start=%r, end=%r, line=%r)' % \ return ('TokenInfo(type=%s, string=%r, start=%r, end=%r, line=%r)' %
((('%d (%s)' % (typ, tok_name[typ])),) + self[1:]) self._replace(type=annotated_type))
def group(*choices): return '(' + '|'.join(choices) + ')' def group(*choices): return '(' + '|'.join(choices) + ')'
def any(*choices): return group(*choices) + '*' def any(*choices): return group(*choices) + '*'