Embedding: How to set globals for PyObject_Call

Scott Gilbert xscottgjunk at yahoo.com
Fri Feb 22 19:23:03 CET 2002


Michael Hudson <mwh at python.net> wrote:
> 
> Oh, I see what's going on.  Another question: what would you expect
> locals() to return?
> 

Well at the least, it should return the same thing it does when you
type locals() at the Python command prompt.  There it is just an alias
for globals().

But for my specific needs (using Python as a high powered
data-structures and expression-evaluator library from C++), I was
planning on having the globals dict be shared among all threads and
having a locals dict per each thread.  I can do this with
PyRun_String(...) because it has me pass in both the globals and
locals.

If I could figure out how to write:

  PyObject* PyObject_CallInScope(
    PyObject* callable, PyObject* args, PyObject* kwds,
    PyObject* globals, PyObject* locals
  );

I'd be happy as a peach.  But so far I've gotten lost trying to
understand what's going on with CodeObjects, ThreadStates,
FrameObjects etc...

> 
> > Well, I hope this is sufficient info if you view this as enough of a
> > problem to fix it.  Thanks for your interest.
> 
> It's probable that Python shouldn't core in these circumstances, at
> least.
> 

:-)

Have a good one and thanks again,
    -Scott



More information about the Python-list mailing list