diff options
author | Raymond Hettinger <python@rcn.com> | 2010-03-09 09:01:46 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-03-09 09:01:46 (GMT) |
commit | 9bd3508530cfcb1687c4a4cddd12a09f234026ee (patch) | |
tree | 13b446bf2ddf94ca2110457f9a8a87f73757acaa /Doc | |
parent | 08090bf36ad25b6fd00fb0fa46368d98e7b3b317 (diff) | |
download | cpython-9bd3508530cfcb1687c4a4cddd12a09f234026ee.zip cpython-9bd3508530cfcb1687c4a4cddd12a09f234026ee.tar.gz cpython-9bd3508530cfcb1687c4a4cddd12a09f234026ee.tar.bz2 |
Add nicer docstrings to namedtuples().
Provides better tooltips and looks better in help().
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/collections.rst | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index c73fbff..a3bbc63 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -679,6 +679,7 @@ Example: _fields = ('x', 'y') <BLANKLINE> def __new__(_cls, x, y): + 'Create a new instance of Point(x, y)' return _tuple.__new__(_cls, (x, y)) <BLANKLINE> @classmethod @@ -690,6 +691,7 @@ Example: return result <BLANKLINE> def __repr__(self): + 'Return a nicely formatted representation string' return 'Point(x=%r, y=%r)' % self <BLANKLINE> def _asdict(self): @@ -704,10 +706,11 @@ Example: return result <BLANKLINE> def __getnewargs__(self): + 'Return self as a plain tuple. Used by copy and pickle.' return tuple(self) <BLANKLINE> - x = _property(_itemgetter(0)) - y = _property(_itemgetter(1)) + x = _property(_itemgetter(0), doc='Alias for field number 0') + y = _property(_itemgetter(1), doc='Alias for field number 1') >>> p = Point(11, y=22) # instantiate with positional or keyword arguments >>> p[0] + p[1] # indexable like the plain tuple (11, 22) |