On Thu, Jun 10, 2021 at 7:31 AM Thomas Güttler <i...@thomas-guettler.de>
wrote:

> Thank you Guido, Chris, Matt and Richard for your feedback to my last
> email.
>
> Here is an updated version called "Template Literals".
>
>
I much prefer:

Alternative Ideas

Instead of backticks for example t'...' could be used.

instead of a new syntax being introduced.

It would be great to consider a variation of this, where `t` is a normal
function in scope that takes the proposed class attributes as arguments,
and simply returns a new object.

Something similar to:

def html(raw_str, parts):
    escaped = []
    for part, is_substitute in parts:
        if is_substitute:
            escaped.append(html_escape(part))
        else:
            escaped.append(part)
   return MarkupSafe("".join(escaped))

With the idea that:

name = 'Bob <the rock>'
fragment = html'Hello: <b>{name}</b>'

results in fragment being:  MarkupSafe("Hello: <b>Bob &lt;the rock&gt;</b>")

----

The equivalent for SQL could return a `Statement` object with appropriate
placeholders used.

If you don't like this approach, it would be nice to include it in the
alternate/rejected sections.

Thanks

Steve
_______________________________________________
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/MMYFG77RSJZQWN7IGVUJIIWRWV2F6D5F/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to