[Python-checkins] r59486 - in python/trunk: Doc/library/collections.rst Lib/collections.py

raymond.hettinger python-checkins at python.org
Thu Dec 13 23:55:52 CET 2007


Author: raymond.hettinger
Date: Thu Dec 13 23:55:52 2007
New Revision: 59486

Modified:
   python/trunk/Doc/library/collections.rst
   python/trunk/Lib/collections.py
Log:
Simplify implementation of __replace__()

Modified: python/trunk/Doc/library/collections.rst
==============================================================================
--- python/trunk/Doc/library/collections.rst	(original)
+++ python/trunk/Doc/library/collections.rst	Thu Dec 13 23:55:52 2007
@@ -396,7 +396,7 @@
                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))
 

Modified: python/trunk/Lib/collections.py
==============================================================================
--- python/trunk/Lib/collections.py	(original)
+++ python/trunk/Lib/collections.py	Thu Dec 13 23:55:52 2007
@@ -70,7 +70,7 @@
             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:


More information about the Python-checkins mailing list