- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here's some Python code (which works as expected in, say, the Idle interpreter):
prog='def _square(x):\n\treturn x*x\n' exec(prog) sq = _square(42) print(sq)
In Idle, this returns 1764 as expected. In the F360 API environment, it gets this result:
NameError: name '_square' is not defined
This is particularly frustrating when, in the VS Code debugger, I can see the name _square defined as a function in the left column.
What can I do to get exec() to work correctly in the API?
Solved! Go to Solution.