diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-04-25 01:29:10 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-04-25 01:29:10 (GMT) |
commit | c7b05920d6536f7edba098d5018a470d35f2e864 (patch) | |
tree | ce0f68baf5c7794f235604c64cde02c12aeed3de /Doc/library/collections.rst | |
parent | 1c596d5604e4fc79944281ddc5baa666f6e27e85 (diff) | |
download | cpython-c7b05920d6536f7edba098d5018a470d35f2e864.zip cpython-c7b05920d6536f7edba098d5018a470d35f2e864.tar.gz cpython-c7b05920d6536f7edba098d5018a470d35f2e864.tar.bz2 |
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 | 93 |
1 files changed, 48 insertions, 45 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index 361da71..dbc47cb 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -179,62 +179,63 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin: .. versionchanged:: 2.6 Added *maxlen* parameter. -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`. + + .. versionadded:: 2.5 - .. versionadded:: 2.5 + .. method:: rotate(n) -.. method:: deque.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 @@ -365,33 +366,35 @@ in Unix:: .. versionadded:: 2.5 -: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: |