[Python-ideas] Briefer string format

David Mertz mertz at gnosis.cx
Thu Aug 6 20:57:00 CEST 2015


I've followed all the posts in this thread, and although my particular
opinion has little significance, I'm definitely -1 on this idea (or
actually -1000).

To my mind is that we have already gone vastly too far in proliferating
near synonyms for templating strings.  Right now, I can type:

>>> "My name is %(first)s %(last)s" % (**locals())

Or:

>>> "My name is {first} {last}".format(**locals())

Or:

>>> string.Template("My name is $first $last").substitute(**locals())

And they all mean the same thing, with pretty much the same capabilities.
I REALLY don't want a 4th or 5th way to spell the same thing... let alone
one with weird semantics with lots of edge cases that are almost impossible
to teach.

I really DO NOT want to spell the same thing as f"..." or !"...", let alone
have every single string magically become a runtime evaluated complex
object like "My name is \{first}".

Yes, I know the oddball edge cases each style supports are slightly
different... but that's exactly the problem.  It's yet another thing to
address an ever-so-slightly different case, where the actual differences
are impossible to explain to students; and where there's frankly nothing
you can't do with just a couple extra characters using str.format() right
now.

Yours, David...


On Sun, Jul 19, 2015 at 4:12 PM, Mike Miller <python-ideas at mgmiller.net>
wrote:

> Have long wished python could format strings easily like bash or perl do,
> ...
> and then it hit me:
>
>     csstext += f'{nl}{selector}{space}{{{nl}'
>
> (This script included whitespace vars to provide a minification option.)
>
> I've seen others make similar suggestions, but to my knowledge they didn't
> include this pleasing brevity aspect.
>
> -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/
>



-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150806/a3cd9ad1/attachment.html>


More information about the Python-ideas mailing list