Thank you, this really looks cool!
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
I've a question. Can I execute a part of a python code and put it's
output in a string? Something like this:
s =
s = exec print Hello World
print s
Greetz,
Noud
--
http://mail.python.org/mailman/listinfo/python-list
jwaixs wrote:
I've a question. Can I execute a part of a python code and put it's
output in a string?
import sys
from cStringIO import StringIO
def exec_and_get_output(code):
... old_stdout = sys.stdout
... sys.stdout = StringIO()
... try:
... exec code in {}, {}