Combined stdout and stderr

25 views
Skip to first unread message

Ram Rachum

unread,
Jan 17, 2014, 4:41:38 PM1/17/14
to python...@googlegroups.com
Hi,

I'd like to have something like `get_both`, except instead of getting the stdout and stderr in separate strings, I'd like to get one string which has both of them, in the order that they were typed. Possible?


Thanks,
Ram.

Vinay Sajip

unread,
Jan 18, 2014, 10:27:29 AM1/18/14
to python...@googlegroups.com

On Friday, January 17, 2014 9:41:38 PM UTC, Ram Rachum wrote:
I'd like to have something like `get_both`, except instead of getting the stdout and stderr in separate strings, I'd like to get one string which has both of them, in the order that they were typed. Possible?
 
Yes, you just pass the same Capture instance as both stdout and stderr, e.g.

from sarge import Capture, run
c = Capture()
run(cmd, stdout=c, stderr=c)

Then c.text would have the text of both the child process stdout and stderr, mixed together (but the order is not always what you might expect).

Regards,

Vinay Sajip
Reply all
Reply to author
Forward
0 new messages