diff options
author | Raymond Hettinger <python@rcn.com> | 2009-05-27 00:38:24 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-05-27 00:38:24 (GMT) |
commit | 089ba7f69012a51c3c809a4d7bde62d67ebbb537 (patch) | |
tree | 182fec8a6a1ad8e89bd9605c8c3c11b302bbc7b5 /Doc/library/collections.rst | |
parent | e261ae0d46d610899fd0822ae9277dd6df54fefe (diff) | |
download | cpython-089ba7f69012a51c3c809a4d7bde62d67ebbb537.zip cpython-089ba7f69012a51c3c809a4d7bde62d67ebbb537.tar.gz cpython-089ba7f69012a51c3c809a4d7bde62d67ebbb537.tar.bz2 |
Fix field name conflicts for named tuples.
Diffstat (limited to 'Doc/library/collections.rst')
-rw-r--r-- | Doc/library/collections.rst | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index 4c64d61..779f154 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -647,8 +647,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): @@ -665,9 +665,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 @@ -675,8 +675,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) |