This is not a duplicate of creating a function object from a string because that is a Python 2 solution with exec
not as a function()
Trying to implement that solution in Python 3 gets this:
d = {}
exec("def f(x): return x")in d
print(d)
returns:
{}
So the question is, how do I create a function in Python 3 from an arbitrary string? (In my case read in from a YAML file, but that's a side issue.)