Re: execute python code and save the stdout as a string
Thank you, this really looks cool! -- http://mail.python.org/mailman/listinfo/python-list
Re: execute python code and save the stdout as a string
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 c