Using PyRun_SimpleString for blocks of Python Code

Rainer Deyke root at rainerdeyke.com
Tue Feb 6 15:10:03 EST 2001


<btheld2 at my-deja.com> wrote in message news:95ph0e$it6$1 at nnrp1.deja.com...
> I am embedded Python in a C++ application and I need to send it blocks
> of code.  For example:
>
> if 1:
>      print "Hi"
>
> How do I do this using PyRun_SimpleString?

Meet mister newline:

char *command =
  "if 1:\n"
  "    print \"Hi\"\n";

PyRun_SimpleString(command);


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list