I need to find a way to call a way to use something with fstring syntax to retrieve information from a string.
My goal is to use the same fstring to create a string, and then decode it.
For example:
def encode():
a = "fizz"
b = "buzz"
return f"{a} / {b}"
def decode(my_string: str):
a = ""
b = ""
f"{a} / {b}" # Something like that, more or less.
print(a) # fizz
print(b) # buzz
I know this example is stupid, but I really need something like that. I work with a proprietary testing software that allow me to call python script, but these scripts can only return values to the software by writing to stdout. And, then, I want to retrieve them in another script called further.
I know there is a possibility to retrieve it with regex, but I want to have the same "fstring" for both functions, to avoid duplication.