tags:

views:

21

answers:

2

how can i receive the console output of any python file (errors, everything printed using the print() command)?

example: main.py starts test.py and gets its output

A: 

i dont know if this will help but im sure it will give you an idea. in vb.net or c#.net we capture console stream using the process StandardOutput like this:

Dim p as Process = Process.Start("cmd")
p.WaitForExit(Integer.MaxValue)
dim output as String = p.StandardOutput
Microgen
A: 

You can use sys.stderr from the sys module. print() uses sys.stdout by default.

import sys

# Print to standard output stream
print("Normal output...")

# Print to standard error stream
print("Error output...", file=sys.stderr)

jtp