remove most uses of list(somedict.keys()) in Demo scripts

This commit is contained in:
Skip Montanaro 2007-08-06 21:07:53 +00:00
parent 28a181cbe8
commit 1e8ce58f5d
17 changed files with 31 additions and 46 deletions

View file

@ -106,9 +106,7 @@ def showbar(dict, title):
n = len(title)
print('='*((70-n)/2), title, '='*((71-n)/2))
list = []
keys = list(dict.keys())
keys.sort()
for key in keys:
for key in sorted(dict.keys()):
n = len(str(key))
list.append((len(dict[key]), key))
maxkeylength = 0
@ -128,8 +126,7 @@ def show(dict, title, maxitems):
n = len(title)
print('='*((70-n)/2), title, '='*((71-n)/2))
list = []
keys = list(dict.keys())
for key in keys:
for key in dict.keys():
list.append((-len(dict[key]), key))
list.sort()
for count, key in list[:maxitems]: