mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Small improvement to the implementation of __replace__().
This commit is contained in:
parent
eeeb9c4445
commit
5681cbce81
2 changed files with 2 additions and 2 deletions
|
|
@ -64,7 +64,7 @@ def namedtuple(typename, field_names, verbose=False):
|
|||
return dict(zip(%(field_names)r, self))
|
||||
def __replace__(self, **kwds):
|
||||
'Return a new %(typename)s object replacing specified fields with new values'
|
||||
return %(typename)s(**dict(self.__asdict__().items() + kwds.items())) \n''' % locals()
|
||||
return %(typename)s(**dict(zip(%(field_names)r, self) + kwds.items())) \n''' % locals()
|
||||
for i, name in enumerate(field_names):
|
||||
template += ' %s = property(itemgetter(%d))\n' % (name, i)
|
||||
if verbose:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue