Why doesn’t an import in an exec in a function work? June 15, 2023 by Tarik How about this: def test(): exec (code, globals()) f()