Evaluation of variable as f-string
Johannes Bauer
dfnsonfsduifb at gmx.de
Fri Jan 27 15:32:00 EST 2023
Am 23.01.23 um 17:43 schrieb Stefan Ram:
> Johannes Bauer <dfnsonfsduifb at gmx.de> writes:
>> x = { "y": "z" }
>> s = "-> {x['y']}"
>> print(s.format(x = x))
>
> x = { "y": "z" }
> def s( x ): return '-> ' + x[ 'y' ]
> print( s( x = x ))
Except this is not at all what I asked for. The string "s" in my example
is just that, an example. I want to render *arbitrary* strings "s"
together with arbitrary dictionaries "x".
Cheers,
Johannes
More information about the Python-list
mailing list