For example, say I have a function like
def example():
print("print('Hello')\nprint('There')")
Is there a way I can run the text outputted without having to run the function, copy the output and rerun the output?
For example, say I have a function like
def example():
print("print('Hello')\nprint('There')")
Is there a way I can run the text outputted without having to run the function, copy the output and rerun the output?
See Can I redirect the stdout into some sort of string buffer? for many ways to capture standard output in a string variable.
Use that when calling the function, then use exec(variable)
to execute the output.