mirror of
https://github.com/python/cpython.git
synced 2025-12-09 02:35:14 +00:00
Add error-checking to namedtuple's _replace() method.
This commit is contained in:
parent
02740f73ff
commit
1b50fd7cb3
3 changed files with 15 additions and 2 deletions
|
|
@ -410,7 +410,10 @@ Example::
|
|||
|
||||
def _replace(self, **kwds):
|
||||
'Return a new Point object replacing specified fields with new values'
|
||||
return self.__class__._make(map(kwds.get, ('x', 'y'), self))
|
||||
result = self.__class__._make(map(kwds.pop, ('x', 'y'), self))
|
||||
if kwds:
|
||||
raise ValueError('Got unexpected field names: %r' % kwds.keys())
|
||||
return result
|
||||
|
||||
x = property(itemgetter(0))
|
||||
y = property(itemgetter(1))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue