]> granicus.if.org Git - python/commitdiff
note how using iter* are unsafe while mutating and document iter(dict)
authorBenjamin Peterson <benjamin@python.org>
Sat, 4 Apr 2009 23:46:34 +0000 (23:46 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sat, 4 Apr 2009 23:46:34 +0000 (23:46 +0000)
Doc/library/stdtypes.rst

index af84f4f0d7f88eb7c263765e66644ff190943810..ae3856ce8e0c786bf51bcfc20efcd3efbe887b54 100644 (file)
@@ -1928,6 +1928,11 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
 
       .. versionadded:: 2.2
 
+   .. describe:: iter(d)
+
+      Return an iterator over the keys of the dictionary.  This is a shortcut
+      for :meth:`iterkeys`.
+
    .. method:: clear()
 
       Remove all items from the dictionary.
@@ -1980,6 +1985,9 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
       Return an iterator over the dictionary's ``(key, value)`` pairs.  See the
       note for :meth:`dict.items`.
 
+      Using :meth:`iteritems` while adding or deleting entries in the dictionary
+      will raise a :exc:`RuntimeError`.
+
       .. versionadded:: 2.2
 
    .. method:: iterkeys()
@@ -1987,6 +1995,9 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
       Return an iterator over the dictionary's keys.  See the note for
       :meth:`dict.items`.
 
+      Using :meth:`iterkeys` while adding or deleting entries in the dictionary
+      will raise a :exc:`RuntimeError`.
+
       .. versionadded:: 2.2
 
    .. method:: itervalues()
@@ -1994,6 +2005,9 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
       Return an iterator over the dictionary's values.  See the note for
       :meth:`dict.items`.
 
+      Using :meth:`itervalues` while adding or deleting entries in the
+      dictionary will raise a :exc:`RuntimeError`.
+
       .. versionadded:: 2.2
 
    .. method:: keys()