New submission from flying sheep:
code inside of the braces of an f-literal should have the exact same lexing
rules than outside *except* for an otherwise unparsable !, :, or } signifying
the end of the replacement field
1. every other language with template literals has it that way
2. it makes sense that the content of the f-literal is a “hole” in which normal
code goes until a !, : or } signifies its end
3. escaping code that will be evaluated reeks of “eval” even though it isn’t
as it is now, it’s very confusing as the contents are neither code nor string
content.
that might be one reason why many people get it wrong and think it can be
stored unevaluatedly and thus provides a security risk (which is obv. wrong)
the whole section after “A consequence of sharing the same syntax as regular
string literals is…” has to be removed and made unnecessary by allowing
everything otherwise legal inside.
e.g. f'spam{(lambda: 1)():<4}' would be legal and be exactly the same as
'{:<4}'.format((lambda: 1)())
----------
messages: 263026
nosy: flying sheep
priority: normal
severity: normal
status: open
title: Change f-literal grammar so that escaping isn’t possible or necessary
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue26713>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com