You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
parsing f-strings -- opening brace of expression gets duplicated when preceeded by backslash #74000
Therefore, the normal string is '\\{x}'.
But the f-string has two parts: '\\{' and an expression Name(id='x', ctx=Load()).
Where does the { in the string part of f-string come from? I can't believe this is the intended behavior... Or, is it?
When I escape the backslash once like above, what gets parsed is actually unescaped backslash. So this might just boil down to inconsistency in parsing \{ in normal vs. f-strings.
I originally discovered this in typed_ast python/typed_ast#34 but the behaviour of ast is identical and since developers of typed_ast aim at compatibility with ast, I bring this issue here.
Activity
mbdevpl commentedon Mar 15, 2017
I get the following output:
Therefore, the normal string is
'\\{x}'.But the f-string has two parts:
'\\{'and an expressionName(id='x', ctx=Load()).Where does the
{in the string part of f-string come from? I can't believe this is the intended behavior... Or, is it?When I escape the backslash once like above, what gets parsed is actually unescaped backslash. So this might just boil down to inconsistency in parsing
\{in normal vs. f-strings.I originally discovered this in typed_ast python/typed_ast#34 but the behaviour of ast is identical and since developers of typed_ast aim at compatibility with ast, I bring this issue here.
serhiy-storchaka commentedon Mar 15, 2017
This is a duplicate of bpo-29104.