[Python-ideas] Briefer string format
Ron Adam
ron3200 at gmail.com
Wed Aug 5 02:32:06 CEST 2015
On 08/04/2015 07:05 PM, Mike Miller wrote:
>
> On 08/04/2015 01:20 PM, Eric V. Smith wrote:
>> It's rejected because .format treats:
>> '{:10}{[name]}'.format(x, y) --> format(x, '10') + format(y['name'])
>
> Isn't this what already happens? Seems odd to go in a different direction
> just avoid an implementation that already exists, even though it may not be
> perfect.
>
> Perhaps it's time to deprecate the troublesome syntax?
>
> Fortunately there's plenty of time before the next version of python to
> figure this out.
Since "f" strings don't exist yet, they could be handled with a different
method.
'{x:10}{y[name]}'.__fmt__(x=x, y=y, name=name)
The string isn't altered here, which may help with error messages, and all
names are supplied as keywords explicitly.
But is there a migration path that would work?
Cheers,
Ron
More information about the Python-ideas
mailing list