File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -436,8 +436,7 @@ function like this::
436436 print("-- I'm sorry, we're all out of", kind)
437437 for arg in arguments: print arg
438438 print('-'*40)
439- keys = keywords.keys()
440- keys.sort()
439+ keys = sorted(keywords.keys())
441440 for kw in keys: print(kw, ':', keywords[kw])
442441
443442It could be called like this::
Original file line number Diff line number Diff line change @@ -400,12 +400,12 @@ Here is a small example using a dictionary::
400400 >>> tel['irv'] = 4127
401401 >>> tel
402402 {'guido': 4127, 'irv': 4127, 'jack': 4098}
403- >>> tel.keys()
403+ >>> list( tel.keys() )
404404 ['guido', 'irv', 'jack']
405- >>> tel.has_key('guido')
406- True
407405 >>> 'guido' in tel
408406 True
407+ >>> 'jack' not in tel
408+ False
409409
410410The :func: `dict ` constructor builds dictionaries directly from lists of
411411key-value pairs stored as tuples. When the pairs form a pattern, list
@@ -435,10 +435,10 @@ Looping Techniques
435435==================
436436
437437When looping through dictionaries, the key and corresponding value can be
438- retrieved at the same time using the :meth: `iteritems ` method. ::
438+ retrieved at the same time using the :meth: `items ` method. ::
439439
440440 >>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}
441- >>> for k, v in knights.iteritems ():
441+ >>> for k, v in knights.items ():
442442 ... print(k, v)
443443 ...
444444 gallahad the pure
You can’t perform that action at this time.
0 commit comments