Dec-24-2019, 12:46 PM
That is an interesting puzzle. After a lot of tries I succeeded in producing a working example.
>>> string_from_file = 'f"Printing {var1}"' >>> string_from_file 'f"Printing {var1}"' >>> var1 = "content of variable" >>> exec('print(eval(string_from_file))') Printing content of variable >>>Although this works I would prefer using
string.format()
. But I am sure you thought about that already.