[Python-ideas] extensible template strings
Guido van Rossum
guido at python.org
Thu Aug 20 01:43:08 CEST 2015
As others have pointed out the syntax is problematic; it's too easy to
accidentally write
foo "bar"
instead of
foo, "bar"
How important is it really to *hide* the fact that this involves a function
call?
Perhaps unrelated, I wonder if in a different world, i18n could have used
_+"string" instead of _("string")? (This would use operator overloading.)
On Wed, Aug 19, 2015 at 4:14 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
>
> 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/
>
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150819/fb09e3cf/attachment.html>
More information about the Python-ideas
mailing list