Is it possible to do lazy formatting of a python string?

37 views Asked by At

Instead of creating a normal formatted string:

s = f"{1+1}" # Which would be "2"

I am receiving a variable with the string "{1+1}" and I need to calculate the expressions inside curly braces to end up with the literal value "2" on the python script.

Does Python have any built-in logic to perform this operation?

0

There are 0 answers