-
-
Couldn't load subscription status.
- Fork 33.3k
Closed as not planned
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
Description
Bug report
Bug description:
a = 'tom'
tp = t'hello world! {a}'
tp2 = t'hello world! {'tom'}'
print(tp)
print(tp2)In the current form, the variable a inside the braces and the literal 'tom' are both strings with the same content, but in actual use a problem occurs. The printed result is as follows:
Template(strings=('hello world! ', ''), interpolations=(Interpolation('tom', 'a', None, ''),))
Template(strings=('hello world! ', ''), interpolations=(Interpolation('tom', "'tom'", None, ''),))
I think this is a highly counterintuitive (very user-unfriendly) issue: it treats the quotation marks as part of the content and includes them in the expression.
CPython versions tested on:
3.14
Operating systems tested on:
macOS
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)