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

raymond.hettinger python-checkins at python.org
Mon Jan 7 21:56:05 CET 2008


Author: raymond.hettinger
Date: Mon Jan 7 21:56:05 2008
New Revision: 59844
Modified:
 python/trunk/Doc/library/collections.rst
 python/trunk/Lib/collections.py
Log:
Use get() instead of pop() for the optimized version of _replace().
Modified: python/trunk/Doc/library/collections.rst
==============================================================================
--- python/trunk/Doc/library/collections.rst	(original)
+++ python/trunk/Doc/library/collections.rst	Mon Jan 7 21:56:05 2008
@@ -531,7 +531,7 @@
 >>> class Point(namedtuple('Point', 'x y')):
 _make = classmethod(tuple.__new__)
 def _replace(self, _map=map, **kwds):
- return self._make(_map(kwds.pop, ('x', 'y'), self))
+ return self._make(_map(kwds.get, ('x', 'y'), self))
 
 Default values can be implemented by using :meth:`_replace` to
 customize a prototype instance::
Modified: python/trunk/Lib/collections.py
==============================================================================
--- python/trunk/Lib/collections.py	(original)
+++ python/trunk/Lib/collections.py	Mon Jan 7 21:56:05 2008
@@ -130,7 +130,7 @@
 'Point class with optimized _make() and _replace() without error-checking'
 _make = classmethod(tuple.__new__)
 def _replace(self, _map=map, **kwds):
- return self._make(_map(kwds.pop, ('x', 'y'), self))
+ return self._make(_map(kwds.get, ('x', 'y'), self))
 
 print Point(11, 22)._replace(x=100)
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /