diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-04-25 01:59:09 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-04-25 01:59:09 (GMT) |
commit | e41251e864e94885d785b5a9bf8f824753316296 (patch) | |
tree | f530db7682d71f4920b22b8d7f84c89727647ab5 /Doc/library/collections.rst | |
parent | 768db92b438038586c1580b711c528363a97d3f4 (diff) | |
download | cpython-e41251e864e94885d785b5a9bf8f824753316296.zip cpython-e41251e864e94885d785b5a9bf8f824753316296.tar.gz cpython-e41251e864e94885d785b5a9bf8f824753316296.tar.bz2 |
Merged revisions 62490 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62490 | benjamin.peterson | 2008-04-24 20:29:10 -0500 (Thu, 24 Apr 2008) | 2 lines
reformat some documentation of classes so methods and attributes are under the class directive
........
Diffstat (limited to 'Doc/library/collections.rst')
-rw-r--r-- | Doc/library/collections.rst | 91 |
1 files changed, 47 insertions, 44 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index 7827700..cff07b9 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -166,59 +166,60 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin: where only the most recent activity is of interest. -Deque objects support the following methods: + Deque objects support the following methods: -.. method:: deque.append(x) + .. method:: append(x) - Add *x* to the right side of the deque. + Add *x* to the right side of the deque. -.. method:: deque.appendleft(x) + .. method:: appendleft(x) - Add *x* to the left side of the deque. + Add *x* to the left side of the deque. -.. method:: deque.clear() + .. method:: clear() - Remove all elements from the deque leaving it with length 0. + Remove all elements from the deque leaving it with length 0. -.. method:: deque.extend(iterable) + .. method:: extend(iterable) - Extend the right side of the deque by appending elements from the iterable - argument. + Extend the right side of the deque by appending elements from the iterable + argument. -.. method:: deque.extendleft(iterable) + .. method:: extendleft(iterable) - Extend the left side of the deque by appending elements from *iterable*. Note, - the series of left appends results in reversing the order of elements in the - iterable argument. + Extend the left side of the deque by appending elements from *iterable*. + Note, the series of left appends results in reversing the order of + elements in the iterable argument. -.. method:: deque.pop() + .. method:: pop() - Remove and return an element from the right side of the deque. If no elements - are present, raises an :exc:`IndexError`. + Remove and return an element from the right side of the deque. If no + elements are present, raises an :exc:`IndexError`. -.. method:: deque.popleft() + .. method:: popleft() - Remove and return an element from the left side of the deque. If no elements are - present, raises an :exc:`IndexError`. + Remove and return an element from the left side of the deque. If no + elements are present, raises an :exc:`IndexError`. -.. method:: deque.remove(value) + .. method:: remove(value) - Removed the first occurrence of *value*. If not found, raises a - :exc:`ValueError`. + Removed the first occurrence of *value*. If not found, raises a + :exc:`ValueError`. -.. method:: deque.rotate(n) + .. method:: rotate(n) + + Rotate the deque *n* steps to the right. If *n* is negative, rotate to + the left. Rotating one step to the right is equivalent to: + ``d.appendleft(d.pop())``. - Rotate the deque *n* steps to the right. If *n* is negative, rotate to the - left. Rotating one step to the right is equivalent to: - ``d.appendleft(d.pop())``. In addition to the above, deques support iteration, pickling, ``len(d)``, ``reversed(d)``, ``copy.copy(d)``, ``copy.deepcopy(d)``, membership testing with @@ -348,32 +349,34 @@ in Unix:: arguments. -:class:`defaultdict` objects support the following method in addition to the -standard :class:`dict` operations: + :class:`defaultdict` objects support the following method in addition to the + standard :class:`dict` operations: + + .. method:: defaultdict.__missing__(key) -.. method:: defaultdict.__missing__(key) + If the :attr:`default_factory` attribute is ``None``, this raises an + :exc:`KeyError` exception with the *key* as argument. - If the :attr:`default_factory` attribute is ``None``, this raises an - :exc:`KeyError` exception with the *key* as argument. + If :attr:`default_factory` is not ``None``, it is called without arguments + to provide a default value for the given *key*, this value is inserted in + the dictionary for the *key*, and returned. - If :attr:`default_factory` is not ``None``, it is called without arguments to - provide a default value for the given *key*, this value is inserted in the - dictionary for the *key*, and returned. + If calling :attr:`default_factory` raises an exception this exception is + propagated unchanged. - If calling :attr:`default_factory` raises an exception this exception is - propagated unchanged. + This method is called by the :meth:`__getitem__` method of the + :class:`dict` class when the requested key is not found; whatever it + returns or raises is then returned or raised by :meth:`__getitem__`. - This method is called by the :meth:`__getitem__` method of the :class:`dict` - class when the requested key is not found; whatever it returns or raises is then - returned or raised by :meth:`__getitem__`. -:class:`defaultdict` objects support the following instance variable: + :class:`defaultdict` objects support the following instance variable: -.. attribute:: defaultdict.default_factory + .. attribute:: defaultdict.default_factory - This attribute is used by the :meth:`__missing__` method; it is initialized from - the first argument to the constructor, if present, or to ``None``, if absent. + This attribute is used by the :meth:`__missing__` method; it is + initialized from the first argument to the constructor, if present, or to + ``None``, if absent. .. _defaultdict-examples: |