mirror of
https://github.com/python/cpython.git
synced 2025-08-15 22:30:42 +00:00
bpo-35224: Reverse evaluation order of key: value in dict comprehensions (GH-14139)
… as proposed in PEP 572; key is now evaluated before value.
https://bugs.python.org/issue35224
(cherry picked from commit c8a35417db
)
Co-authored-by: Jörn Heissler <joernheissler@users.noreply.github.com>
This commit is contained in:
parent
fa23bd286f
commit
874ff65e0a
8 changed files with 53 additions and 7 deletions
|
@ -212,6 +212,11 @@ class NamedExpressionAssignmentTest(unittest.TestCase):
|
|||
|
||||
self.assertEqual(a, False)
|
||||
|
||||
def test_named_expression_assignment_16(self):
|
||||
a, b = 1, 2
|
||||
fib = {(c := a): (a := b) + (b := a + c) - b for __ in range(6)}
|
||||
self.assertEqual(fib, {1: 2, 2: 3, 3: 5, 5: 8, 8: 13, 13: 21})
|
||||
|
||||
|
||||
class NamedExpressionScopeTest(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue