A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-May/153510.html below:

[Python-Dev] PEP 572 and f-strings

[Python-Dev] PEP 572 and f-strings [Python-Dev] PEP 572 and f-stringsChris Angelico rosuav at gmail.com
Sat May 12 09:03:22 EDT 2018
On Sat, May 12, 2018 at 9:11 PM, Eric V. Smith <eric at trueblade.com> wrote:
> I don't think it matters to its acceptance, but PEP 572 should at least
> mention that the := syntax means that you cannot use assignment expressions
> in f-strings.
>
> As I wrote in a python-ideas email, f'{x:=4}' already has a defined meaning
> (even if no one is using it).

As with lambda functions, you can't write them the simple way.
However, you can parenthesize it, and then it works fine.

>>> f"@{(lambda: 42)}@"
'@<function <lambda> at 0x7f09e18c4268>@'
>>> f"@{(y := 1)}@"
'@1@'
>>> y
1

ChrisA
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4