python function in pipe

7stud bbxx789_05ss at
Sat Apr 28 19:35:50 CEST 2007

On Apr 28, 7:37 am, Bart <u... at> wrote:
> Hi everyone!
> Im using module that gives errors to stderr/stdout  (generated by SWIG)
> Problem is that I need to parse this errors/information from module.
> os.popen3 looks nice but this executes  command  not  function.
> Is there any solution?
> Best regards
> Bart.

Maybe something like this:
def someFunc():
    print "hello"
    raise ValueError


import subprocess

print "Main executing"
    p  = subprocess.Popen(["python", ""],

    result = p.wait()
    if result == 0:
        print "output:",
        print "output before error:",
        print "error:",

except (OSError, TypeError, ValueError), e:
    print "subprocess was never started"
    print e

More information about the Python-list mailing list