Python 3.12 released
Python 3.12 released
Posted Oct 3, 2023 18:21 UTC (Tue) by Karellen (subscriber, #67644)In reply to: Python 3.12 released by NYKevin
Parent article: Python 3.12 released
the braces temporarily "cancel" the enclosing quotes
I mean, I guess that's how quotes work in the sh command substitution syntax $(....), but that's shell. It feels... weird and icky to put that sort of thing in a "real" programming language like Python!
Posted Oct 3, 2023 19:13 UTC (Tue)
by NYKevin (subscriber, #129325)
[Link] (1 responses)
> Many languages that allow similar syntactic constructs (normally called āstring interpolationā) allow quote reuse and arbitrary nesting. These languages include JavaScript, Ruby, C#, Bash, Swift and many others. The fact that many languages allow quote reuse can be a compelling argument in favour of allowing it in Python. This is because it will make the language more familiar to users coming from other languages.
Posted Oct 3, 2023 22:11 UTC (Tue)
by mathstuf (subscriber, #69389)
[Link]
In [2]: f'a dict: { {1: 2, "a": 4}}'
Soā¦`}}` is not an escape for `}`ā¦sometimes?
In [6]: f'a dict: { {1: 2, "a":: 4} }'
I'm not sure why this column marker seems to care so much about the first key when the second key's `::` is the actual problem. Maybe it gets caught as a format specifier somehow?
Python 3.12 released
Python 3.12 released
Out[2]: "a dict: {1: 2, 'a': 4}"
Cell In[6], line 1
f'a dict: { {1: 2, "a":: 4} }'
^
SyntaxError: f-string: invalid syntax