diff options
author | Raymond Hettinger <python@rcn.com> | 2007-12-13 22:55:52 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-12-13 22:55:52 (GMT) |
commit | 04a9a0e904d31875bc7bbcbe0899076194d3cb6f (patch) | |
tree | c134bd02f47813c57fcd565b568d7c57320ddf1e | |
parent | e552959184ff58bfdcd72a6cc8d1460aaf82537d (diff) | |
download | cpython-04a9a0e904d31875bc7bbcbe0899076194d3cb6f.zip cpython-04a9a0e904d31875bc7bbcbe0899076194d3cb6f.tar.gz cpython-04a9a0e904d31875bc7bbcbe0899076194d3cb6f.tar.bz2 |
Simplify implementation of __replace__()
-rw-r--r-- | Doc/library/collections.rst | 2 | ||||
-rw-r--r-- | Lib/collections.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index 403d00f..fc52408 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -396,7 +396,7 @@ Example:: return dict(zip(('x', 'y'), self)) def __replace__(self, **kwds): 'Return a new Point object replacing specified fields with new values' - return Point(**dict(zip(('x', 'y'), self) + kwds.items())) + return Point(**dict(zip(('x', 'y'), self), **kwds)) x = property(itemgetter(0)) y = property(itemgetter(1)) diff --git a/Lib/collections.py b/Lib/collections.py index e551f20..0b0a26b 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -70,7 +70,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(zip(%(field_names)r, self) + kwds.items())) \n''' % locals() + return %(typename)s(**dict(zip(%(field_names)r, self), **kwds)) \n''' % locals() for i, name in enumerate(field_names): template += ' %s = property(itemgetter(%d))\n' % (name, i) if verbose: |