[C++-sig] Properly handling prints and feedback when automatically executing a script

Adam Preble adam.preble at gmail.com
Sat Jan 28 00:43:10 CET 2012


I have opted to have my C++ main call an autoexec.py script by default when
compiled to support the interpreter.  Ultimately, I will want to run some
Python code w/o user intervention to do it.  I have come up with this
somewhat naive implementation:

http://pastebin.com/NTytF6iQ

It starts the script but isn't handling prints inside the script.  They
just get completely suppressed.  How can I get them to come out to the
console?

For this matter, this naive implementation just runs in a console.  I'd
love to be able to embed a prettier UI element but it looks like I'd have
to come up with a lot of code myself.  I'm trying to do this for a 3d
project, so it would make some sense to have a console UI embedded in I
could tilde into.  Ultimately, I'd want to be able to autoexec the script,
while having this other console for similarly manipulating state--with
appropriate concurrency controls.  Is there a known path for doing that
kind of thing?

The only place I really saw something like this happening at all was with
Blender, and the code for doing that in particularly didn't just pop right
out at me, and in the IRC channel I wasn't given any other hints than to
look at the code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20120127/62e29b5b/attachment.html>


More information about the Cplusplus-sig mailing list