Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3745)

Side by Side Diff: Doc/library/collections.rst

Issue 10617: Collections ABCs can’t be linked to
Patch Set: Created 2 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 :mod:`collections` --- High-performance container datatypes 2 :mod:`collections` --- High-performance container datatypes
3 =========================================================== 3 ===========================================================
4 4
5 .. module:: collections 5 .. module:: collections
6 :synopsis: High-performance datatypes 6 :synopsis: High-performance datatypes
7 .. moduleauthor:: Raymond Hettinger <python@rcn.com> 7 .. moduleauthor:: Raymond Hettinger <python@rcn.com>
8 .. sectionauthor:: Raymond Hettinger <python@rcn.com> 8 .. sectionauthor:: Raymond Hettinger <python@rcn.com>
9 9
10 .. versionadded:: 2.4 10 .. versionadded:: 2.4
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 if key in self: 851 if key in self:
852 del self[key] 852 del self[key]
853 OrderedDict.__setitem__(self, key, value) 853 OrderedDict.__setitem__(self, key, value)
854 854
855 855
856 .. _abstract-base-classes: 856 .. _abstract-base-classes:
857 857
858 ABCs - abstract base classes 858 ABCs - abstract base classes
859 ---------------------------- 859 ----------------------------
860 860
861 The collections module offers the following ABCs: 861 The collections module offers the following :term:`ABCs <abstract base class>`:
862 862
863 ========================= ===================== ====================== ====== ============================================== 863 ========================= ===================== ====================== ====== ==============================================
864 ABC Inherits Abstract Methods Mixin Methods 864 ABC Inherits from Abstract Methods Mixin Methods
865 ========================= ===================== ====================== ====== ============================================== 865 ========================= ===================== ====================== ====== ==============================================
866 :class:`Container` ``__contains__`` 866 :class:`Container` ``__contains__``
867 :class:`Hashable` ``__hash__`` 867 :class:`Hashable` ``__hash__``
868 :class:`Iterable` ``__iter__`` 868 :class:`Iterable` ``__iter__``
869 :class:`Iterator` :class:`Iterable` ``next`` ``__it er__`` 869 :class:`Iterator` :class:`Iterable` ``next`` ``__it er__``
870 :class:`Sized` ``__len__`` 870 :class:`Sized` ``__len__``
871 :class:`Callable` ``__call__`` 871 :class:`Callable` ``__call__``
872 872
873 :class:`Sequence` :class:`Sized`, ``__getitem__`` ``__co ntains__``. ``__iter__``, ``__reversed__``, 873 :class:`Sequence` :class:`Sized`, ``__getitem__`` ``__co ntains__``. ``__iter__``, ``__reversed__``,
874 :class:`Iterable`, ``inde x``, and ``count`` 874 :class:`Iterable`, ``inde x``, and ``count``
875 :class:`Container` 875 :class:`Container`
876 876
877 :class:`MutableSequence` :class:`Sequence` ``__setitem__`` Inheri ted Sequence methods and 877 :class:`MutableSequence` :class:`Sequence` ``__setitem__``, Inheri ted :class:`Sequence` methods and
878 ``__delitem__``, ``appe nd``, ``reverse``, ``extend``, ``pop``, 878 ``__delitem__``, ``appe nd``, ``reverse``, ``extend``, ``pop``,
879 and ``insert`` ``remo ve``, and ``__iadd__`` 879 ``insert`` ``remo ve``, and ``__iadd__``
880 880
881 :class:`Set` :class:`Sized`, ``__le __``, ``__lt__``, ``__eq__``, ``__ne__``, 881 :class:`Set` :class:`Sized`, ``__le __``, ``__lt__``, ``__eq__``, ``__ne__``,
882 :class:`Iterable`, ``__gt __``, ``__ge__``, ``__and__``, ``__or__``, 882 :class:`Iterable`, ``__gt __``, ``__ge__``, ``__and__``, ``__or__``,
883 :class:`Container` ``__su b__``, ``__xor__``, and ``isdisjoint`` 883 :class:`Container` ``__su b__``, ``__xor__``, and ``isdisjoint``
884 884
885 :class:`MutableSet` :class:`Set` ``add`` and Inheri ted Set methods and 885 :class:`MutableSet` :class:`Set` ``add``, Inheri ted :class:`Set` methods and
886 ``discard`` ``clea r``, ``pop``, ``remove``, ``__ior__``, 886 ``discard`` ``clea r``, ``pop``, ``remove``, ``__ior__``,
887 ``__ia nd__``, ``__ixor__``, and ``__isub__`` 887 ``__ia nd__``, ``__ixor__``, and ``__isub__``
888 888
889 :class:`Mapping` :class:`Sized`, ``__getitem__`` ``__co ntains__``, ``keys``, ``items``, ``values``, 889 :class:`Mapping` :class:`Sized`, ``__getitem__`` ``__co ntains__``, ``keys``, ``items``, ``values``,
890 :class:`Iterable`, ``get` `, ``__eq__``, and ``__ne__`` 890 :class:`Iterable`, ``get` `, ``__eq__``, and ``__ne__``
891 :class:`Container` 891 :class:`Container`
892 892
893 :class:`MutableMapping` :class:`Mapping` ``__setitem__`` and Inheri ted Mapping methods and 893 :class:`MutableMapping` :class:`Mapping` ``__setitem__``, Inheri ted :class:`Mapping` methods and
894 ``__delitem__`` ``pop` `, ``popitem``, ``clear``, ``update``, 894 ``__delitem__`` ``pop` `, ``popitem``, ``clear``, ``update``,
895 and `` setdefault`` 895 and `` setdefault``
896 896
897 897
898 :class:`MappingView` :class:`Sized` ``__le n__`` 898 :class:`MappingView` :class:`Sized` ``__le n__``
899 :class:`ItemsView` :class:`MappingView`, ``__co ntains__``,
900 :class:`Set` ``__it er__``
899 :class:`KeysView` :class:`MappingView`, ``__co ntains__``, 901 :class:`KeysView` :class:`MappingView`, ``__co ntains__``,
900 :class:`Set` ``__it er__``
901 :class:`ItemsView` :class:`MappingView`, ``__co ntains__``,
902 :class:`Set` ``__it er__`` 902 :class:`Set` ``__it er__``
903 :class:`ValuesView` :class:`MappingView` ``__co ntains__``, ``__iter__`` 903 :class:`ValuesView` :class:`MappingView` ``__co ntains__``, ``__iter__``
904 ========================= ===================== ====================== ====== ============================================== 904 ========================= ===================== ====================== ====== ==============================================
905 905
906
907 .. class:: Container
908 Hashable
909 Sized
910 Callable
911
912 ABCs for classes that provide respectively the methods
913 :meth:`__contains__ <__contains__>`, :meth:`__hash__ <__hash__>`,
914 :meth:`__len__ <__len__>`, and :meth:`__call__ <__call__>`.
915
916 .. class:: Iterable
917
918 ABC for classes that provide the :meth:`__iter__ <__iter__>` method.
919 See also :term:`iterable`.
920
921 .. class:: Iterator
922
923 ABC for classes that provide the :meth:`__iter__ <__iter__>` and
924 :meth:`next <next>` methods. See also :term:`iterator`.
925
926 .. class:: Sequence
927 MutableSequence
928
929 ABCs for read-only and mutable :term:`sequences <sequence>`.
930
931 .. class:: Set
932 MutableSet
933
934 ABCs for read-only and mutable sets.
935
936 .. class:: Mapping
937 MutableMapping
938
939 ABCs for read-only and mutable :term:`mappings <mapping>`.
940
941 .. class:: MappingView
942 ItemsView
943 KeysView
944 ValuesView
945
946 ABCs for mapping, items, keys, and values :term:`views <view>`.
947
948
906 These ABCs allow us to ask classes or instances if they provide 949 These ABCs allow us to ask classes or instances if they provide
907 particular functionality, for example:: 950 particular functionality, for example::
908 951
909 size = None 952 size = None
910 if isinstance(myvar, collections.Sized): 953 if isinstance(myvar, collections.Sized):
911 size = len(myvar) 954 size = len(myvar)
912 955
913 Several of the ABCs are also useful as mixins that make it easier to develop 956 Several of the ABCs are also useful as mixins that make it easier to develop
914 classes supporting container APIs. For example, to write a class supporting 957 classes supporting container APIs. For example, to write a class supporting
915 the full :class:`Set` API, it only necessary to supply the three underlying 958 the full :class:`Set` API, it only necessary to supply the three underlying
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 1006
964 .. seealso:: 1007 .. seealso::
965 1008
966 * Latest version of the `Python source code for the collections abstract base classes 1009 * Latest version of the `Python source code for the collections abstract base classes
967 <http://svn.python.org/view/python/branches/release27-maint/Lib/_abcoll.py? view=markup>`_ 1010 <http://svn.python.org/view/python/branches/release27-maint/Lib/_abcoll.py? view=markup>`_
968 1011
969 * `OrderedSet recipe <http://code.activestate.com/recipes/576694/>`_ for an 1012 * `OrderedSet recipe <http://code.activestate.com/recipes/576694/>`_ for an
970 example built on :class:`MutableSet`. 1013 example built on :class:`MutableSet`.
971 1014
972 * For more about ABCs, see the :mod:`abc` module and :pep:`3119`. 1015 * For more about ABCs, see the :mod:`abc` module and :pep:`3119`.
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7