Replaced XXX.keys() calls with idiomatic python 3 calls that are compatible with python 2 such as eg:
 * replaced "y = xxx.keys()" or "y = list(xxx.keys())" with just "y = list(xxx)"
 * replaced "sorted(xxx.keys())" or "sorted(list(xxx.keys()))" with just "sorted(xxx)"
 * replaced "if not A in B.keys():" with "if A not in B:"
 * replaced "for A in B.keys():"  with "for A in B:"

See also https://python-future.org/compatible_idioms.html
https://python-future.org/compatible_idioms.html#dict-keys-values-items-as-a-list
This commit is contained in:
Per A. Brodtkorb
2020-03-20 18:51:19 +01:00
parent ef1edacc20
commit 033c18fd9f
54 changed files with 164 additions and 193 deletions

View File

@@ -106,7 +106,7 @@ def makeRandomPens(num, cache):
c = random.choice(colours)
t = random.randint(1, 4)
if not (c, t) in cache.keys():
if (c, t) not in cache:
cache[(c, t)] = wx.Pen(c, t)
pens.append( cache[(c, t)] )
@@ -120,7 +120,7 @@ def makeRandomBrushes(num, cache):
for i in range(num):
c = random.choice(colours)
if not c in cache.keys():
if c not in cache:
cache[c] = wx.Brush(c)
brushes.append( cache[c] )