|
|
Subscribe / Log in / New account

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!


to post comments

Python 3.12 released

Posted Oct 3, 2023 19:13 UTC (Tue) by NYKevin (subscriber, #129325) [Link] (1 responses)

Although PEP 701 does cite bash as inspiration, it also cites several "real" programming languages, including Ruby (šŸ”„ take: Ruby is just Python with different syntax):

> 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.

Python 3.12 released

Posted Oct 3, 2023 22:11 UTC (Tue) by mathstuf (subscriber, #69389) [Link]

I just wish that some of the corner cases didn't exist (Python 3.11):

In [2]: f'a dict: { {1: 2, "a": 4}}'
Out[2]: "a dict: {1: 2, 'a': 4}"

So…`}}` is not an escape for `}`…sometimes?

In [6]: f'a dict: { {1: 2, "a":: 4} }'
Cell In[6], line 1
f'a dict: { {1: 2, "a":: 4} }'
^
SyntaxError: f-string: invalid syntax

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?


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds