News for hackers. Stuff that matters.
Re:Python's new t-strings by tetha on Monday April 21, 2025 @07:36AM (#43750750)
Or you could use this in a library like sh with

    sh(t"stat {some_file}")
With t-strings you could run proper escaping over the contents of `some_file` before passing it to a shell.

I'd have to take a look at the order things happen in shell, but you might even be able to increase security/foot-gun-potential a little bit here by turning this into something like `stat "$( base64 -d [base64 encoded content of some_file] )"`.

Re:Python's new t-strings by nhumrich on Monday April 21, 2025 @08:38AM (#43751303)
You should check out PEP 787
Re:Python's new t-strings by tetha on Monday April 21, 2025 @02:00PM (#43754650)
Hmm, PEP-787 has some interesting discussions around it. I'll have to sort my thoughts on these aspects a bit.
Re:Python's new t-strings by pauleveritt on Monday April 21, 2025 @02:46PM (#43755129)
We really should just point most of these comments at that PEP. Thanks for getting it out so fast.
Re:Python's new t-strings by zahlman on Monday April 21, 2025 @05:42PM (#43756826)
Oh! I missed this one because I've been looking specifically at the Packaging forum rather than the PEPs forum. This looks like a brilliant use case. (I'm aiming for wide compatibility - back to 3.6 - with my current projects, but I look forward to trying this out if and when it's accepted and implemented.)

Now if only the overall `subprocess` interface weren't so complex....

Re:Python's new t-strings by Flimm on Tuesday April 22, 2025 @08:09AM (#43761190)
PEP 787 – Safer subprocess usage using t-strings https://peps.python.org/pep-0787/
Re:Python's new t-strings by dhruvrajvanshi on Monday April 21, 2025 @04:34PM (#43756169)
Not Python but this is exactly the idea behind zx

https://github.com/google/zx