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