On Thu, Jun 10, 2021 at 2:58 PM Ricky Teachey <[email protected]> wrote:
> Something I don't understand is whether there is anything about this
> proposed feature that can't be accomplished with a simple function...
>
> ....
> And use it like this:
>
> >>> templify("Here, have some {foo}.")
> TemplateLiteral(template = " Here, have some {foo}.", tokens = (("Here,
> have some ", True), ("spam & eggs", False)))
>
>
> What is it about this task that requires it being handled at the language
> level...?
>
AIUI, that is hard to do without language support, because the function
templify can't easily access the value of 'foo' because the binding only
exists in the caller's scope.
So for a simple function to be used, you'd have to pass in the placeholder
values explicitly as separate arguments, which somewhat defeats the point.
Steve
_______________________________________________
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/VGZKVTAY5CY5KNZCKY7FP2CPJX4N3NIU/
Code of Conduct: http://python.org/psf/codeofconduct/