> On May 17, 2018, at 9:56 AM, Nick Coghlan <ncogh...@gmail.com> wrote:
> 
>> On 15 May 2018 at 16:23, Eric V. Smith <e...@trueblade.com> wrote:
>> I'm busy at the sprints, so I don't have a lot of time to think about this.
>> 
>> However, let me just say that recursive format specs are supported, to a 
>> depth of 1.
>> 
>> >>> width=10
>> >>> f'{"test":{width}}'
>> 'test      '
>> 
>> So first the string is basically expanded to:
>> f'{"test":10}'
>> Then the string is formatted again to produce the final result.
>> 
>> That is why the braces must match: they're being used for recursive format 
>> specs. There's no mechanism for having braces that aren't inspected by the 
>> f-string machinery.
> 
> https://www.python.org/dev/peps/pep-0536/ also seems worth noting (I don't 
> actually understand the specifics of that PEP myself,  just making sure that 
> Ken's aware of its existence if this is an area of interest)

Yes, that’s a good point. Thanks for remembering this PEP. 

I disagree with much of the PEP and it’s language, such as “These limitations 
serve no purpose ...”. And I especially object to the fact that it doesn’t take 
in to account the effect of its proposed changes on other python 
implementations or on tools like editors, linters, static type checkers, etc., 
all of which would have to be modified. 

Not that those are insurmountable issues or mean that we should never improve 
f-strings, but they do need to be carefully considered and given weight in the 
decision process. 

Eric

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to