I have a setup that looks as following:
from io import StringIO
from contextlib import redirect_stdout
f = StringIO()
with redirect_stdout(f):
exec("""'echo "test"'""")
s = f.getvalue()
print("return value:",s)
Is there a reason why the return value s does not contain "test"? How can I access this value?