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]
|
yield [y, x/y]
|
||||||
stuff = list(g())
|
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
|
# Using a statement-local name
|
||||||
stuff = [[(f(x) as y), x/y] for x in range(5)]
|
stuff = [[(f(x) as y), x/y] for x in range(5)]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue