mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +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]:
|
||||
|
|
|
@ -87,7 +87,7 @@ def test():
|
|||
return
|
||||
if debug: print('done.')
|
||||
if debug > 1:
|
||||
for key in list(m.trans.keys()):
|
||||
for key in m.trans.keys():
|
||||
if key is None or len(key) < histsize:
|
||||
print(repr(key), m.trans[key])
|
||||
if histsize == 0: print(repr(''), m.trans[''])
|
||||
|
|
|
@ -172,10 +172,9 @@ def printtree(f, tree, indent, p):
|
|||
createpage(p[1:], tree, p)
|
||||
return
|
||||
|
||||
kl = list(tree.keys())
|
||||
kl = sorted(tree.keys())
|
||||
|
||||
if l > 1:
|
||||
kl.sort()
|
||||
if indent > 0:
|
||||
# Create a sub-list
|
||||
f.write('<LI>'+p[1:]+'\n<UL>')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue