What's a good way to exec a bunch of python code, like exec mycode, and capture everything it prints to stdout into a string?
-
4Have a look at this answer. stackoverflow.com/questions/3906232/… It is replacing stdout for the time of execution.Reiner Gerecke– Reiner Gerecke2011-02-05 00:06:47 +00:00Commented Feb 5, 2011 at 0:06
-
@Reiner: Although this question is worded better, it's basically a dup of that one (and that one has a fantastic answer!). Should this be closed & pointed to that one?Gerrat– Gerrat2011-02-05 00:12:39 +00:00Commented Feb 5, 2011 at 0:12
-
ah i thought of doing something like that then decided it wouldnt work for some reason , but i guess not!Claudiu– Claudiu2011-02-05 00:18:08 +00:00Commented Feb 5, 2011 at 0:18
Add a comment
|