summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-05-27 02:24:45 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-05-27 02:24:45 (GMT)
commita68cad13aee2f3df45bde6f3217c02b9b270d2e5 (patch)
tree72fa10650da4427ad1014d531eae644af6803e60 /Doc/library
parent55d8828f982d4b03ef25db61cf0b8b50f1d1cf76 (diff)
downloadcpython-a68cad13aee2f3df45bde6f3217c02b9b270d2e5.zip
cpython-a68cad13aee2f3df45bde6f3217c02b9b270d2e5.tar.gz
cpython-a68cad13aee2f3df45bde6f3217c02b9b270d2e5.tar.bz2
Fix field name conflicts for named tuples.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/collections.rst12
1 files changed, 6 insertions, 6 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index 3801cc8..1ecd17a 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -673,8 +673,8 @@ Example:
<BLANKLINE>
_fields = ('x', 'y')
<BLANKLINE>
- def __new__(cls, x, y):
- return tuple.__new__(cls, (x, y))
+ def __new__(_cls, x, y):
+ return _tuple.__new__(_cls, (x, y))
<BLANKLINE>
@classmethod
def _make(cls, iterable, new=tuple.__new__, len=len):
@@ -691,9 +691,9 @@ Example:
'Return a new OrderedDict which maps field names to their values'
return OrderedDict(zip(self._fields, self))
<BLANKLINE>
- def _replace(self, **kwds):
+ def _replace(_self, **kwds):
'Return a new Point object replacing specified fields with new values'
- result = self._make(map(kwds.pop, ('x', 'y'), self))
+ result = _self._make(map(kwds.pop, ('x', 'y'), _self))
if kwds:
raise ValueError('Got unexpected field names: %r' % kwds.keys())
return result
@@ -701,8 +701,8 @@ Example:
def __getnewargs__(self):
return tuple(self)
<BLANKLINE>
- x = property(itemgetter(0))
- y = property(itemgetter(1))
+ x = _property(_itemgetter(0))
+ y = _property(_itemgetter(1))
>>> p = Point(11, y=22) # instantiate with positional or keyword arguments
>>> p[0] + p[1] # indexable like the plain tuple (11, 22)