[Python-ideas] Let’s make escaping in f-literals impossible

Eric V. Smith eric at trueblade.com
Tue Aug 30 08:13:05 EDT 2016


On 08/30/2016 07:02 AM, Philipp A. wrote:
> Very cool of you to get this going!

Thanks for raising the issue.

> I hope the outcome is to ban escapes within braced code parts of
> f-literals for 3.6 and add them “the right way” in 3.7: f'foo{ bar['\n']
> }baz'

There's debate on if that's the right way, and I personally think it's
probably not. Personally, I'd be happy with the only change being to not
allow backslashes inside braces. But that's not an argument that I'm
willing to get into now, since I need to get this rolling for beta 1.

> Also the name “f-strings” is really misleading: They’re composite
> expressions that evaluate to strings. They can only be considered
> strings if you have no braced code parts in them. So I’m also still in
> favor of renaming them (e.g. to “f-literals”).

I don't have much of an opinion here. I think there's not a lot of
confusion to be had by calling them f-strings, but I think someone who
works with teaching python might have a better handle on that.

Eric.




More information about the Python-ideas mailing list