hy.eval called from python function and lfor #2345
-
I'm trying to use hy by calling it from a python function, but it seems that
The
which does not work, but setting |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I think this boils down to the most confusing aspect of Python's
and indeed
Here's a Stack Overflow question about the latter. It's ridiculous, but it seems to be a won't-fix so long as the Python folks are concerned. |
Beta Was this translation helpful? Give feedback.
-
Oh wow, that is very unexpected to me. Thanks for the great and quick answer. So if I want to isolate the hy and python namespaces the following should work?
|
Beta Was this translation helpful? Give feedback.
-
That works, thanks. From reading the code I expected it not to work though. If I see correctly But it works, so I'm happy. Thanks for the help! |
Beta Was this translation helpful? Give feedback.
I think this boils down to the most confusing aspect of Python's
exec
: "If exec gets two separate objects as globals and locals, the code will be executed as if it were embedded in a class definition", not as a function as you might expect. Notice thatand indeed