language and
I need to capture the output of PyRun_String(), PyEval_EvalCode(), or
whatever as a char * (or wchar_t * or whatever) rather than have it go
to stdout.
I'm using Python 3.3.2 under plain C, not C++
And, while I'm interrupting everyone's evening, another question:
language and
I need to capture the output of PyRun_String(), PyEval_EvalCode(), or
whatever as a char * (or wchar_t * or whatever) rather than have it go
to stdout.
I'm using Python 3.3.2 under plain C, not C++
And, while I'm interrupting everyone's evening, another question:
; Well, I eventually want to add an import hook, but for now I'd rather
> > just
> > get the import statement working normally again.
> > I have embedded python as a scripting engine in my application. To do
> > this,
> > I create a new empty module, run the sc
ication. To do
> this,
> I create a new empty module, run the script text using PyRun_String()
> passing the module's __dict__ as locals and globals. This populates the
> module's __dict__ with the resulting object references from the script
> text.
Instead of PyRun_St
Well, I eventually want to add an import hook, but for now I'd rather just
get the import statement working normally again.
I have embedded python as a scripting engine in my application. To do this,
I create a new empty module, run the script text using PyRun_String()
passing the mod
En Tue, 08 Apr 2008 22:01:18 -0300, Patrick Stinson
<[EMAIL PROTECTED]> escribió:
> I'm creating a module with PyModule_New(), and running a string buffer as
> the module's text using PyRun_String and passing the module's __dict__ to
> locals and globals.
Why? D
I'm creating a module with PyModule_New(), and running a string buffer as
the module's text using PyRun_String and passing the module's __dict__ to
locals and globals. I'm having a problem using the import statement from
within PyRun_String(). It complains about "__import_
to use main_dict.update(dlfl_dict)
> (Python code) or PyDict_Update(main_dict, dlfl_dict) (in C code).
Yep.
> > I tried PyObject *rstring = PyRun_String( cmd, Py_file_input,
> > dlfl_dict, dlfl_dict );
> > This worked, but has the side effect of not allowing other commands
ict) (in C code).
> I tried PyObject *rstring = PyRun_String( cmd, Py_file_input,
> dlfl_dict, dlfl_dict );
> This worked, but has the side effect of not allowing other commands
> like "execfile"
The idea is to copy all items from dlfl_dict into main_dict, and use
main_di
What command do you mean when you say "update main_dict with
dlfl_dict"?
I tried PyObject *rstring = PyRun_String( cmd, Py_file_input,
dlfl_dict, dlfl_dict );
This worked, but has the side effect of not allowing other commands
like "execfile"
I was able to type that before,
Stuart <[EMAIL PROTECTED]> wrote:
...
> PyObject *rstring = PyRun_String( cmd, Py_file_input, main_dict,
> dlfl_dict );
You're passing difl_dict as the "locals" to PyRun_String -- but a
function has its own locals, so it won't use those locals. Just update
main
ict( main );
PyObject* dlfl_dict = PyModule_GetDict( dlfl );
PyObject *rstring = PyRun_String( cmd, Py_file_input, main_dict,
dlfl_dict );
rstring returns NULL and then PyErr_Fetch( &object, &data,
&traceback ); gets the traceback string as I mentioned above.
Hopefully, there is just a simple solution. Thanks :)
--
http://mail.python.org/mailman/listinfo/python-list
0, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> escribió:
>
> > I'm using PyRun_String with Py_single_input for a python interpreter
> > embedded in my application. I'm using Py_single_input. Py_single input
> > is what I want, but it seems to output to stdout. Befor
En Mon, 18 Jun 2007 01:45:38 -0300, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> escribió:
> I'm using PyRun_String with Py_single_input for a python interpreter
> embedded in my application. I'm using Py_single_input. Py_single input
> is what I want, but it seems to output
I'm using PyRun_String with Py_single_input for a python interpreter
embedded in my application. I'm using Py_single_input. Py_single input
is what I want, but it seems to output to stdout. Before when I was
using Py_eval_input I was able to grab the result so I could print it
in
I'm using PyRun_String with Py_single_input for a python interpreter
embedded in my application. I'm using Py_single_input. Py_single input
is what I want, but it seems to output to stdout. Before when I was
using Py_eval_input I was able to grab the result so I could print it
in
d to python embedding
> it). I have a function that executes a string buffer of python code,
> fetches a function from its global dictionary then calls it.
Why don't you use a documented function like PyRun_String or similar, as
in the subject line?
> /*Now for the fun par
Hi I'm getting extremely odd behavior. First of all, why isn't
PyEval_EvalCode documented anywhere? Anyway, I'm working on
blender's
python integration (it embeds python, as opposed to python embedding
it). I have a function that executes a string buffer of python code,
fetches a function from
Am Thu, 09 Mar 2006 20:06:54 +0100 hat Duncan Booth
<[EMAIL PROTECTED]> geschrieben:
> Matthias wrote:
>
>> Log("Marker 1");
>> Py_XDECREF( PyRun_String( "print 'Hi!'", Py_single_input, Dict, Dict) );
>> Log("Marker 2")
Matthias wrote:
> Log("Marker 1");
> Py_XDECREF( PyRun_String( "print 'Hi!'", Py_single_input, Dict, Dict) );
> Log("Marker 2");
>
> The output looks like
>
> Marker 1
> Hi!
> Hi!
> Marker 2
>
> Obviously Hi! is printe
Hello,
I encountered a strange problem today. I try to do this:
Log("Marker 1");
Py_XDECREF( PyRun_String( "print 'Hi!'", Py_single_input, Dict, Dict) );
Log("Marker 2");
The output looks like
Marker 1
Hi!
Hi!
Marker 2
Obviously Hi! is printed twice. I&
Here's a snippet of code that demonstrates my problem:
result = PyRun_String ("import math", Py_file_input, pdict,pdict);
result = PyRun_String ("math.sqrt(-1)", Py_file_input, pdict,pdict);
result = PyRun_String ("math.pow(2,1024)", Py_file_input,
pdict,
22 matches
Mail list logo