Embedding: Question about modules

S

smilechaser

Hi All,

A question about embedding:

If I take the example code on embedding (Section 5.3 of Extending and
Embedding the Python Interpreter 2.4) and add the lines:

PyRun_SimpleString("import sys");
PyRun_SimpleString("print globals()");

Just after the part where the code loads the module, and then I have a
script that looks like:

# mod_test.py
def foo(x):
for g in globals():
print g

The first printout of the globals shows the sys module, but the second
one does not. Can someone explain why this is ? And how do I make the
sys module accessible to the module I load (as per the 5.3 example).
TIA,
smilechaser
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,216
Messages
2,571,120
Members
47,721
Latest member
MathewLoyd

Latest Threads

Top