On 2023-01-29 10:18:00 +0100, Johannes Bauer wrote: > Am 29.01.23 um 05:27 schrieb Thomas Passin: > > IOW, perhaps there is a more practical way to accomplish what you want. > > Except that we don't know what that is. > > Well, I don't know. I pretty much want a generic Python mechanism that > allows for exactly what f-strings do: execute arbitrary Python snippets of > code
That exists. Use eval (or exec). > and format them in one go. Include an f-string in the code you eval. > In other words, I want to be able to do things like that, given an > *arbitrary* dictionary x and a string s As I wrote before: An f-string isn't a string. It's a grammatical construct. So you want to execute Python code which is what eval and exec do. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | h...@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!"
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list