PEP 572: Add another alternate spelling

This commit is contained in:
Chris Angelico 2018-03-24 20:25:27 +11:00
parent af7b76f545
commit c5b251e756
1 changed files with 4 additions and 0 deletions

View File

@ -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)]