summaryrefslogtreecommitdiffstats
path: root/Doc/library/collections.rst
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-02-09 03:48:16 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-02-09 03:48:16 (GMT)
commit0dbdab2557d7e1f83929981a12d7d2619a2a3804 (patch)
tree8520e32284d37f1b86e40f0ab58a46dcba53bb2e /Doc/library/collections.rst
parent7aebb64bab2ef75c6d9ae55da9ae7049f05c8670 (diff)
downloadcpython-0dbdab2557d7e1f83929981a12d7d2619a2a3804.zip
cpython-0dbdab2557d7e1f83929981a12d7d2619a2a3804.tar.gz
cpython-0dbdab2557d7e1f83929981a12d7d2619a2a3804.tar.bz2
Add another usage note for collections.Set
Diffstat (limited to 'Doc/library/collections.rst')
-rw-r--r--Doc/library/collections.rst9
1 files changed, 8 insertions, 1 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index 1e32f99..493e22a 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -58,7 +58,7 @@ ABC Inherits Abstract Methods Mixin M
``insert``, ``remove``, and ``__iadd__``
and ``__len__``
-:class:`Set` \(1) \(2) :class:`Sized`, ``__len__``, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``,
+:class:`Set` :class:`Sized`, ``__len__``, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``,
:class:`Iterable`, ``__iter__``, and ``__gt__``, ``__ge__``, ``__and__``, ``__or__``
:class:`Container` ``__contains__`` ``__sub__``, ``__xor__``, and ``isdisjoint``
@@ -118,6 +118,13 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin:
semantics are fixed), redefine :meth:`__le__` and
then the other operations will automatically follow suit.
+(3)
+ The :class:`Set` mixin provides a :meth:`_hash` method to compute a hash value
+ for the set; however, :meth:`__hash__` is not defined because not all sets
+ are hashable or immutable. To add set hashabilty using mixins,
+ inherit from both :meth:`Set` and :meth:`Hashable`, then define
+ ``__hash__ = Set._hash``.
+
(For more about ABCs, see the :mod:`abc` module and :pep:`3119`.)