Issue #9507: Named tuple repr will now automatically display the right

name in a tuple subclass.
This commit is contained in:
Raymond Hettinger 2010-08-08 01:13:42 +00:00
parent a6b76ba52e
commit d331ce9e66
4 changed files with 15 additions and 2 deletions

View file

@ -240,7 +240,7 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
return result \n
def __repr__(self):
'Return a nicely formatted representation string'
return '%(typename)s(%(reprtxt)s)' %% self \n
return self.__class__.__name__ + '(%(reprtxt)s)' %% self \n
def _asdict(self):
'Return a new OrderedDict which maps field names to their values'
return OrderedDict(zip(self._fields, self)) \n