[Python-ideas] extensible template strings
Wes Turner
wes.turner at gmail.com
Thu Aug 20 02:30:05 CEST 2015
On Aug 19, 2015 6:23 PM, "Mike Miller" <python-ideas at mgmiller.net> wrote:
>
> I also like this feature (of extensible string prefixes) and have
encountered it in my research with Scala, Nim, and to some extent C#. It
feels like the right way to go, and could make a lot of code just
"disappear". It's somewhat analogous to context managers/with statement.
>
> So far I'm calling these "string processors" and wonder how much
resistance there is to the idea. In short it means you would be able to
define your own processors, as Yury mentioned:
>
> f'' ==> Format String
> i'' ==> i18n
> sql'' ==> Escaped SQL
> re'' ==> builds RegEx object
shell
shellquoted
html
html5
html,utf8
XML
LaTeX
These would be convenient,
But as TypedStrings with attributes and serializations (e.g. IPython/Jupter
_repr_html_, _repr_*_
; MarkupSafe)
The string prefix syntaxes:
* aren't backward compatible
* don't port
* obfuscate functional composition in effect for (notoriously difficult to
trace/debug) a function which needs to access a thread local (such as for
charset, language, [fmt]
>
> We could include a number of common needs while users could implement
those specific to their applications.
>
> (Should we keep them separate from existing prefixes? I'm not sure about
that part, perhaps we could advise that these new ones to be more than one
character and not be composable.)
>
> Is there interest in this feature?
>
> -Mike
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150819/d48a6dfa/attachment.html>
More information about the Python-ideas
mailing list