Armin Ronacher  committed ad2904e

PEP 0372: added notice on comparing

  • Participants
  • Parent commits 161c203
  • Branches default

Comments (0)

Files changed (1)

File pep-0372.txt

     >>> d.byindex(2)
     ('foo', 'bar')
-    If there is no key for index an `IndexError` is raised.
+    If there is no key for index an `IndexError` is raised.  Slices are not
+    supported.
     Returns the index of a key.  If the key does not exist, a `ValueError` is
     Supports reverse iteration by key.
+``odict.__eq__()`` / ``odict.__ne__()``
+    Compares the odict to another object.  If it's compared to another
+    odict the ordering of items is taken into account, otherwise only
+    the keys and values.
+    Ordered dicts are sorted by their items.  ``cmp(od1, od2)`` is
+    equivalent to ``cmp(od1.items(), od2.items())`` if both ``od1``
+    and ``od2`` are ordered dicts.  Otherwise the regular dict comparison
+    kicks in.
 Questions and Answers
     >>> odict(l)
     collections.odict([('a', 42), ('x', 0), ('b', 23), ('c', 19)])
+Is the ordered dict a dict subclass?
+    Yes.  Like ``defaultdict``, ``odict`` subclasses ``dict``.
+Does ``odict.pop()`` support list-like popping of items?
+    No.  Neither ``odict.__getitem__()`` nor ``odict.pop()`` support
+    retrieving or deleting items by index.  Slices are not supported
+    either.  This would introduce ambiguities if integers or slice
+    objects are used as dict keys.
+    As a matter of fact, ``odict`` does not implement the ``Sequence``
+    interface.
 Example Implementation