redirect output of functions to a string or file

Peter Schneider-Kamp petersc at stud.ntnu.no
Mon Jul 10 18:14:47 EDT 2000


"Fernando Rodríguez" wrote:
> 
>     Is there a way to tell Python to "automagically" redirect the output
> of _all_ functions to a string or file? O:-)

You can redirect standard output:

import sys
sys.stdout = open("somefile.output","w")

then you can just print the result of the functions.

hope that helps - if not, send code or wait for better replies,
Peter
--
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter at schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de




More information about the Python-list mailing list