PEP 572: Mention another rejected syntax

This commit is contained in:
Chris Angelico 2018-04-13 22:40:36 +10:00
parent ed718f5186
commit cf7e061167
1 changed files with 13 additions and 2 deletions

View File

@ -297,7 +297,18 @@ Broadly the same semantics as the current proposal, but spelled differently.
``with`` and ``except`` statements, where a nearly-identical syntax has
different semantics).
2. Adorning statement-local names with a leading dot::
2. ``EXPR -> NAME``::
stuff = [[f(x) -> y, x/y] for x in range(5)]
This syntax is inspired by languages such as R and Haskell, and some
programmable calculators. (Note that a left-facing arrow ``y <- f(x)`` is
not possible in Python, as it would be interpreted as less-than and unary
minus.) This syntax has a slight advantage over 'as' in that it does not
conflict with ``with`` and ``except`` statements, but otherwise is
equivalent.
3. Adorning statement-local names with a leading dot::
stuff = [[(f(x) as .y), x/.y] for x in range(5)] # with "as"
stuff = [[(.y := f(x)), x/.y] for x in range(5)] # with ":="
@ -309,7 +320,7 @@ Broadly the same semantics as the current proposal, but spelled differently.
become the current recommendation if its advantages are found to outweigh
its cost.
3. Adding a ``where:`` to any statement to create local name bindings::
4. Adding a ``where:`` to any statement to create local name bindings::
value = x**2 + 2*x where:
x = spam(1, 4, 7, q)