On Sun, 27 Jun 2021 at 08:11, Paul Bryan <pbr...@anode.ca> wrote:
>
> It looks like you're suggesting hard-coding specific language escape 
> conventions into f-strings?

That's how I understood the proposal too. Hard coding specific
conventions shouldn't be part of a language construct IMO.

> What if instead you were to allow delegation to some filter function? Then, 
> it's generic and extensible.

> def html(value: Any):
>     filtered = ... # filter here
>     return filtered
>
> f'{!!html}<a href="{url}">...<a>'

Well, there's already a way of handling that:

f'<a href="{html(url)}">...<a>'

So all you're saving is a bit of typing. Yes, I'm aware that there are
nuances here that I'm dismissing, but this feels like what Nick was
talking about in his post, where he pointed out that this is a
variation on PEP 501, and the reasons for deferring that PEP still
apply. It's not that the idea isn't attractive, it's just that once
you've considered all the ways you can "nearly" do this already with
existing tools, the benefits that remain are so small that they don't
warrant a language change.

Paul
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/IS2GKFL57CUCSEMG7NHRVPQLPQEJKRNM/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to