]> granicus.if.org Git - python/commitdiff
Merged revisions 74762 via svnmerge from
authorEzio Melotti <ezio.melotti@gmail.com>
Sun, 13 Sep 2009 08:08:32 +0000 (08:08 +0000)
committerEzio Melotti <ezio.melotti@gmail.com>
Sun, 13 Sep 2009 08:08:32 +0000 (08:08 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r74762 | ezio.melotti | 2009-09-13 07:48:45 +0300 (Sun, 13 Sep 2009) | 1 line

  more list()s on dictviews
........

Doc/c-api/mapping.rst
Doc/library/collections.rst
Doc/library/doctest.rst
Doc/library/modulefinder.rst
Doc/library/shelve.rst

index 1d0ed5052810ab432af9ac38c79874feade823b5..5b2de1478309b430903d379409b90aa14a2df6b4 100644 (file)
@@ -51,20 +51,20 @@ Mapping Protocol
 .. cfunction:: PyObject* PyMapping_Keys(PyObject *o)
 
    On success, return a list of the keys in object *o*.  On failure, return *NULL*.
-   This is equivalent to the Python expression ``o.keys()``.
+   This is equivalent to the Python expression ``list(o.keys())``.
 
 
 .. cfunction:: PyObject* PyMapping_Values(PyObject *o)
 
    On success, return a list of the values in object *o*.  On failure, return
-   *NULL*. This is equivalent to the Python expression ``o.values()``.
+   *NULL*. This is equivalent to the Python expression ``list(o.values())``.
 
 
 .. cfunction:: PyObject* PyMapping_Items(PyObject *o)
 
    On success, return a list of the items in object *o*, where each item is a tuple
    containing a key-value pair.  On failure, return *NULL*. This is equivalent to
-   the Python expression ``o.items()``.
+   the Python expression ``list(o.items())``.
 
 
 .. cfunction:: PyObject* PyMapping_GetItemString(PyObject *o, char *key)
index d7907b077671b5d0b54cdfc710487741d49b7898..cd38956bffb77a194d0f481a513188ba579bfd34 100644 (file)
@@ -669,7 +669,7 @@ Example:
                'Return a new Point object replacing specified fields with new values'
                result = _self._make(map(kwds.pop, ('x', 'y'), _self))
                if kwds:
-                   raise ValueError('Got unexpected field names: %r' % kwds.keys())
+                   raise ValueError('Got unexpected field names: %r' % list(kwds.keys()))
                return result
    <BLANKLINE>
            def __getnewargs__(self):
index 2d0f48a0f5dec0154ab2eb98daf5a05d8f5eb8c0..2aa3ae163f1a2687d68e002437f8445af351cb59 100644 (file)
@@ -701,8 +701,7 @@ is vulnerable!  One workaround is to do ::
 
 instead.  Another is to do ::
 
-   >>> d = foo().items()
-   >>> d.sort()
+   >>> d = sorted(foo().items())
    >>> d
    [('Harry', 'broomstick'), ('Hermione', 'hippogryph')]
 
index 6db02ff408bd703593d9e0348e06f4844a4eb07e..41b387bb993939f871523e78e08a9c595130854d 100644 (file)
@@ -84,7 +84,7 @@ The script that will output the report of bacon.py::
    print('Loaded modules:')
    for name, mod in finder.modules.items():
        print('%s: ' % name, end='')
-       print(','.join(mod.globalnames.keys()[:3]))
+       print(','.join(list(mod.globalnames.keys())[:3]))
 
    print('-'*50)
    print('Modules not imported:')
index 35ed84c69d5091061f55c35ec3a56df0ec91f863..10242fd2c4f8ed3d8d55c1044d7a898437fc4640 100644 (file)
@@ -141,8 +141,8 @@ object)::
                    # such key)
    del d[key]      # delete data stored at key (raises KeyError
                    # if no such key)
-   flag = key in d   # true if the key exists
-   klist = d.keys() # a list of all existing keys (slow!)
+   flag = key in d        # true if the key exists
+   klist = list(d.keys()) # a list of all existing keys (slow!)
 
    # as d was opened WITHOUT writeback=True, beware:
    d['xx'] = range(4)  # this works as expected, but...