[Python-Dev] PEP-498: Literal String Formatting

Yury Selivanov yselivanov.ml at gmail.com
Mon Aug 10 20:44:08 CEST 2015

On 2015-08-10 2:37 PM, Eric V. Smith wrote:
>> Besides, any expression you have to calculate can go in a local that will get
>> >interpolated.  The same goes for any !r or other formatting modifiers.  In an
>> >i18n context, you want to stick to the simplest possible substitution
>> >placeholders.
> This is why I think PEP-498 isn't the solution for i18n. I'd really like
> to be able to say, in a debugging context:
> print('a:{self.a} b:{self.b} c:{self.c} d:{self.d}')
> without having to create locals to hold these 4 values.

Why can't we restrict expressions in f-strings to
attribute/item getters?

I.e. allow f'{foo.bar.baz}' and f'{self.foo["bar"]}' but
disallow f'{foo.bar(baz=something)}'


More information about the Python-Dev mailing list