[Python-ideas] Briefer string format

Mark Lawrence breamoreboy at yahoo.co.uk
Mon Jul 20 03:31:31 CEST 2015


On 20/07/2015 00:59, Paul Sokolovsky wrote:
> Hello,
>
> On Sun, 19 Jul 2015 16:35:01 -0700
> Mike Miller <python-ideas at mgmiller.net> wrote:
>
> []
>
>>       csstext += f'{nl}{key}{space}{{{nl}'
>>
>> An "f-formatted" string could automatically format with the locals
>> dict. Not yet sure about globals, and unicode only suggested for
>> now.
>
> "Not sure" sounds convincing. Deal - let's keep being explicit rather
> than implicit. Brevity?
>
> def _(fmt, dict):
>      return fmt.format(**dict)
> __ = globals()
> ___ = locals()
>
> foo = 42
>
> _("{foo}", __())
>
>
> If that's not terse enough, you can take Python3, and go thru Unicode
> planes looking for funky-looking letters, then you hopefully can reduce
> to
>
> .("{foo}", .())
>
> Where dots aren't dots, but funky-looking letters.
>

Good grief, April 1st already?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Python-ideas mailing list