Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-02-09 Thread greg
Ben Sizer wrote: Yes, this seems to fix it, thanks. But why? Can some Python guru explain why these two dictionaries must be the same? (Or what steps we must take if we want them to be separate?) What's happening is that the import statement is binding the name 'sys' in the locals, not the

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-21 Thread Aahz
In article b11e6e8a-98a6-43d1-b311-652fedbe7...@h5g2000yqh.googlegroups.com, Ben Sizer kylo...@gmail.com wrote: I have the following C++ code and am attempting to embed Python 2.5, but although the import sys statement works, attempting to reference sys.path from inside a function after that

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-15 Thread Ben Sizer
On Jan 14, 4:37 pm, Ivan Illarionov ivan.illario...@gmail.com wrote: On Jan 14, 1:49 pm, Ben Sizer kylo...@gmail.com wrote: No, I don't want to do anything with sys.path apart from see it. I just wanted my original question answered, not a guess at my intent and a solution for something

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-14 Thread Ben Sizer
On Jan 14, 1:55 am, Ivan Illarionov ivan.illario...@gmail.com wrote: Ben Sizer kylo...@gmail.com wrote: What am I doing wrong? What are you trying to achieve? If you want to modify sys.path I suggest using Python/C API directly: No, I don't want to do anything with sys.path apart from see

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-14 Thread Ivan Illarionov
On Jan 14, 1:49 pm, Ben Sizer kylo...@gmail.com wrote: No, I don't want to do anything with sys.path apart from see it. I just wanted my original question answered, not a guess at my intent and a solution for something I'm not doing. ;)  Thanks though! Again - why can I not reference sys from

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-14 Thread Ben Sizer
On Jan 14, 4:37 pm, Ivan Illarionov ivan.illario...@gmail.com wrote: I would try to use ourNamespace_ dict for both globals and locals in PyRun_String call. I will try it when I get home. However I would like to be able to treat them as separate dictionaries, as I want to be able to import

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-14 Thread Ivan Illarionov
On Jan 14, 8:00 pm, Ben Sizer kylo...@gmail.com wrote: I will try it when I get home. However I would like to be able to treat them as separate dictionaries, as I want to be able to import some symbols and modules at a global level, but be able to clear out objects introduced at the local

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-14 Thread Ivan Illarionov
On Jan 14, 8:17 pm, Ivan Illarionov ivan.illario...@gmail.com wrote: On Jan 14, 8:00 pm, Ben Sizer kylo...@gmail.com wrote: I will try it when I get home. However I would like to be able to treat them as separate dictionaries, as I want to be able to import some symbols and modules at a

'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-13 Thread Ben Sizer
I have the following C++ code and am attempting to embed Python 2.5, but although the import sys statement works, attempting to reference sys.path from inside a function after that point fails. It's as if it's not treating it as a normal module but as any other global variable which I'd have to

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-13 Thread Ivan Illarionov
Ben Sizer kylo...@gmail.com wrote: What am I doing wrong? What are you trying to achieve? If you want to modify sys.path I suggest using Python/C API directly: (boilerplate removed) PyImport_ImportModule(sys) PyObject_GetAttrString(sysmod_pointer, path) PyList_Insert(pathobj_pointer, 0,

Re: 'Import sys' succeeds in C++ embedded code, but module is not fully visible

2009-01-13 Thread Christian Heimes
Ivan Illarionov schrieb: Ben Sizer kylo...@gmail.com wrote: What am I doing wrong? What are you trying to achieve? If you want to modify sys.path I suggest using Python/C API directly: (boilerplate removed) PyImport_ImportModule(sys) PyObject_GetAttrString(sysmod_pointer, path)