[Python-checkins] r62005 - in python/trunk/Doc: c-api/mapping.rst library/rfc822.rst tutorial/datastructures.rst

georg.brandl python-checkins at python.org
Fri Mar 28 13:22:12 CET 2008


Author: georg.brandl
Date: Fri Mar 28 13:22:12 2008
New Revision: 62005

Modified:
   python/trunk/Doc/c-api/mapping.rst
   python/trunk/Doc/library/rfc822.rst
   python/trunk/Doc/tutorial/datastructures.rst
Log:
Phase out has_key usage in the tutorial; correct docs for PyMapping_HasKey*.


Modified: python/trunk/Doc/c-api/mapping.rst
==============================================================================
--- python/trunk/Doc/c-api/mapping.rst	(original)
+++ python/trunk/Doc/c-api/mapping.rst	Fri Mar 28 13:22:12 2008
@@ -36,15 +36,15 @@
 .. cfunction:: int PyMapping_HasKeyString(PyObject *o, char *key)
 
    On success, return ``1`` if the mapping object has the key *key* and ``0``
-   otherwise.  This is equivalent to the Python expression ``o.has_key(key)``.
-   This function always succeeds.
+   otherwise.  This is equivalent to ``o[key]``, returning ``True`` on success
+   and ``False`` on an exception.  This function always succeeds.
 
 
 .. cfunction:: int PyMapping_HasKey(PyObject *o, PyObject *key)
 
-   Return ``1`` if the mapping object has the key *key* and ``0`` otherwise.  This
-   is equivalent to the Python expression ``o.has_key(key)``.  This function always
-   succeeds.
+   Return ``1`` if the mapping object has the key *key* and ``0`` otherwise.
+   This is equivalent to ``o[key]``, returning ``True`` on success and ``False``
+   on an exception.  This function always succeeds.
 
 
 .. cfunction:: PyObject* PyMapping_Keys(PyObject *o)

Modified: python/trunk/Doc/library/rfc822.rst
==============================================================================
--- python/trunk/Doc/library/rfc822.rst	(original)
+++ python/trunk/Doc/library/rfc822.rst	Fri Mar 28 13:22:12 2008
@@ -260,7 +260,7 @@
 :class:`Message` instances also support a limited mapping interface. In
 particular: ``m[name]`` is like ``m.getheader(name)`` but raises :exc:`KeyError`
 if there is no matching header; and ``len(m)``, ``m.get(name[, default])``,
-``m.has_key(name)``, ``m.keys()``, ``m.values()`` ``m.items()``, and
+``name in m``, ``m.keys()``, ``m.values()`` ``m.items()``, and
 ``m.setdefault(name[, default])`` act as expected, with the one difference
 that :meth:`setdefault` uses an empty string as the default value.
 :class:`Message` instances also support the mapping writable interface ``m[name]

Modified: python/trunk/Doc/tutorial/datastructures.rst
==============================================================================
--- python/trunk/Doc/tutorial/datastructures.rst	(original)
+++ python/trunk/Doc/tutorial/datastructures.rst	Fri Mar 28 13:22:12 2008
@@ -480,8 +480,7 @@
 The :meth:`keys` method of a dictionary object returns a list of all the keys
 used in the dictionary, in arbitrary order (if you want it sorted, just apply
 the :meth:`sort` method to the list of keys).  To check whether a single key is
-in the dictionary, either use the dictionary's :meth:`has_key` method or the
-:keyword:`in` keyword.
+in the dictionary, use the :keyword:`in` keyword.
 
 Here is a small example using a dictionary::
 
@@ -497,8 +496,6 @@
    {'guido': 4127, 'irv': 4127, 'jack': 4098}
    >>> tel.keys()
    ['guido', 'irv', 'jack']
-   >>> tel.has_key('guido')
-   True
    >>> 'guido' in tel
    True
 


More information about the Python-checkins mailing list