PEP 572: Add another alternate spelling
This commit is contained in:
parent
af7b76f545
commit
c5b251e756
|
@ -163,6 +163,10 @@ These list comprehensions are all approximately equivalent::
|
|||
yield [y, x/y]
|
||||
stuff = list(g())
|
||||
|
||||
# Using a mutable cache object (various forms possible)
|
||||
c = {}
|
||||
stuff = [[c.update(y=f(x)) or c['y'], x/c['y']] for x in range(5)]
|
||||
|
||||
# Using a statement-local name
|
||||
stuff = [[(f(x) as y), x/y] for x in range(5)]
|
||||
|
||||
|
|
Loading…
Reference in New Issue