what are PyObject *globals and PyObject *locals ?

O

Olivier Sessink

Hi all,

I want to make a value available to the global namespace of an embedded
python interpreter. Several functions of the Python/C API feature a
PyObject *globals and a PyObject *locals, so my guess is that these can be
used for this purpose. Unfortunately, the Python/C API does not describe
how this works.

If I want for example, to create a variable MyVar that can be read by the
python code in some filename, to be run with PyRun_AnyFile();, how can I
do this?

Or do I misunderstand the API, and can Py_InitModule() register both
functions *and* variables? (and how to register the variable then?)

regards,
Olivier

(I know extending is the preferred solution, unfortunately I was not aware
of this some years ago)

------------ And now a word from our sponsor ------------------
For a quality usenet news server, try DNEWS, easy to install,
fast, efficient and reliable. For home servers or carrier class
installations with millions of users it will allow you to grow!
---- See http://netwinsite.com/sponsor/sponsor_dnews.htm ----
 

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

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,167
Latest member
SusanaSwan
Top