quoting

Python3.12 SyntaxWarning on triplequoted string `d` must be `\d`

Python3.12 SyntaxWarning on triplequoted string `d` must be `\d` Question: After updating to Python 3.12, I get warnings about invalid escape sequence on some triple-quotes comments. Is this a new restriction? I have the habit of documenting code using triple-quoted string, but this has never been a problem prior to Python 3.12. python3 –version Python …

Total answers: 1

f-string: unmatched '(' in line with function call

f-string: unmatched '(' in line with function call Question: I’m trying to use f-strings in python to substitute some variables into a string that I’m printing, and I’m getting a syntax error. Here’s my code: print(f"{index+1}. {value[-1].replace("[Gmail]/", ”)}") I only started having the problem after I added the replace. I’ve checked plenty of times and …

Total answers: 4

Python module to shellquote/unshellquote?

Python module to shellquote/unshellquote? Question: Is there anything in the Python standard library that will properly parse/unparse strings for using in shell commands? I’m looking for the python analog to perl’s String::ShellQuote::shell_quote: $ print String::ShellQuote::shell_quote(“hello”, “stack”, “overflow’s”, “quite”, “cool”) hello stack ‘overflow”’s’ quite cool And, even more importantly, something which will work in the reverse …

Total answers: 8