1

Not able to redirect shared library output to /dev/null in python

view story
linux-howto

http://stackoverflow.com – I'm trying to redirect the output of the constructor of an object that is created by a shared library to /dev/null. The side effect of the construction is the printing of lots of junk that I don't need. The code is as follows: f = open("/dev/null", 'w') tmpErr = sys.stderr tmpOut = sys.stdout sys.stderr = f sys.stdout = f foo = Foo(param1, param2) sys.stderr = tmpErr sys.stdout = tmpOut f.close() If I replace the function call with a simple print (print "hello", for example) or a call to a local function, the redirection seems to work. Also, using the ">&" operator in the shell (tcsh) I (HowTos)