On 10/22/2020 8:29 AM, Chris Angelico wrote:
On Thu, Oct 22, 2020 at 8:22 PM Steven D'Aprano <[email protected]> wrote:
Another problem is that using only a literal/display form as a target
means you can't pre-assemble a pattern and apply it later:

     # Match only the given domain.
     domain = get_wanted_domain()
     pattern = 'email: {name}@%s' % domain
     # ... now what?
Right, and you can't do that with f-strings on the RHS either. The
specific thing you're asking about could easily be implemented as a
feature of the minilanguage itself, but I'm not sure it'd actually be
needed. Building patterns for future parsing is simply not the job of
this feature - use a regex if you need that.

In the case of f-strings, the fallback is str.format(), which uses the exact same format specifiers. What's the equivalent when you need dynamic 'f-string assignment targets'?

Eric
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/CZ7E3APYA6EHTLLIEDIV4W3ZXIJGSMJC/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to