The output of "exec dir" vs. just "dir"
farber at cpan.org
Wed Mar 15 05:12:19 CET 2000
when I enter "dir" on the Python interactive prompt,
I get "<built-in function dir>". But entering "exec 'dir'",
outputs nothing. To get the same result, I have to enter
"exec 'print dir'" (w/o double quotes). The same is true for:
3 vs. exec 3
globals() vs. exec "globals()"
Why is it this way? Can I change it? I am asking, because
I am simulating Python's prompt by calling Py_CompileString() +
PyEval_EvalCode(), which is probably the same, what "exec"
does. It works okay, but I'd like to get rid of the difference
described above. Thank you.
PS: The complete code is at
More information about the Python-list