[Python-ideas] Briefer string format

Chris Angelico rosuav at gmail.com
Mon Jul 20 02:04:13 CEST 2015

On Mon, Jul 20, 2015 at 9:50 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> On 7/19/2015 7:12 PM, Mike Miller 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}'
> Are the unbalanced braces here and in the followup intentional?

I expect they are - compare the percent formatting example:

> csstext += '%s%s%s{%s' % (nl, key, space, nl)

The double open brace makes for a literal open brace in the end
result. It's the same ugliness as trying to craft a regular expression
to match Windows path names without raw string literals, so I
completely sympathize with the desire for something better. But I
don't think f"fmt" is it :)


More information about the Python-ideas mailing list