On Thu, Jun 10, 2021 at 10:12 AM Stestagg <stest...@gmail.com> wrote:

>
> On Thu, Jun 10, 2021 at 2:58 PM Ricky Teachey <ri...@teachey.org> 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
>
>
Got it now. Should have been able to figure that out on my own thanks for
explaining!

Makes me wonder if stepping back and thinking, instead, about a way to
automatically (optionally?) put the current calling context dictionary(ies)
somewhere that a called function can get at it/them, so it can do what it
wants with the context.

---
Ricky.

"I've never met a Kentucky man who wasn't either thinking about going home
or actually going home." - Happy Chandler
_______________________________________________
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/IM5B7NKEIKPZKWIMTFEZHHBO2XOUOPG5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to