> On May 12, 2018, at 9:03 AM, Chris Angelico <rosuav at gmail.com> wrote: > >> 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 > Yes, but just as PEP 498 mentions lambdas, I think 572 should mention f-strings, and point out this workaround. Eric
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