Assume that we have a string
function_string = 'def main():\n\treturn(1)'
How can this be compiled as a function during runtime and then be executed?
This is my current attempt, unfortunately it raises a NameError expressing that main
is not defined:
self.run():
exec(self.formatted_function_string) # similar to 'function_string' in the example
print(main())