]> granicus.if.org Git - python/commitdiff
A few more fixes to the tutorial
authorNeal Norwitz <nnorwitz@gmail.com>
Fri, 31 Aug 2007 03:46:28 +0000 (03:46 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Fri, 31 Aug 2007 03:46:28 +0000 (03:46 +0000)
Doc/tutorial/controlflow.rst
Doc/tutorial/datastructures.rst

index 0d9a21de6317c99c2e8573788f87ff0d02872bc3..ebd531e7238936dee76fd3871932fa04c9b97578 100644 (file)
@@ -436,8 +436,7 @@ function like this::
        print("-- I'm sorry, we're all out of", kind)
        for arg in arguments: print arg
        print('-'*40)
-       keys = keywords.keys()
-       keys.sort()
+       keys = sorted(keywords.keys())
        for kw in keys: print(kw, ':', keywords[kw])
 
 It could be called like this::
index 77088f399e7c8128145ef664aec32928a9585b6d..20bade5b15780d7d9c07b53c8c5ed496807a62ae 100644 (file)
@@ -400,12 +400,12 @@ Here is a small example using a dictionary::
    >>> tel['irv'] = 4127
    >>> tel
    {'guido': 4127, 'irv': 4127, 'jack': 4098}
-   >>> tel.keys()
+   >>> list(tel.keys())
    ['guido', 'irv', 'jack']
-   >>> tel.has_key('guido')
-   True
    >>> 'guido' in tel
    True
+   >>> 'jack' not in tel
+   False
 
 The :func:`dict` constructor builds dictionaries directly from lists of
 key-value pairs stored as tuples.  When the pairs form a pattern, list
@@ -435,10 +435,10 @@ Looping Techniques
 ==================
 
 When looping through dictionaries, the key and corresponding value can be
-retrieved at the same time using the :meth:`iteritems` method. ::
+retrieved at the same time using the :meth:`items` method. ::
 
    >>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}
-   >>> for k, v in knights.iteritems():
+   >>> for k, v in knights.items():
    ...     print(k, v)
    ...
    gallahad the pure