mirror of
https://github.com/python/cpython.git
synced 2025-09-11 19:27:07 +00:00
remove most uses of list(somedict.keys()) in Demo scripts
This commit is contained in:
parent
28a181cbe8
commit
1e8ce58f5d
17 changed files with 31 additions and 46 deletions
|
@ -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]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue