can we save print msg into a file when script running ?

Steve Holden steve at
Wed Oct 12 09:13:12 CEST 2005

black wrote:
> hi all~
> in my .py file there are a few print to trace out some message and i
> wonder if we can save it into a specified file when that script get
> running. if so, i may just check that file to c how the script is
> running. can anyone show me a right direction ?
> one million tks~
On Unix platforms you can run your script with a redirection of the 
standard output:

python > somefile.txt &

[The ampersand runs the command in the background]. Then you can monitor 
the content of the output file with

tail -f somefile.txt

which will show you the last part of the file and further additions as 
long as you let the tail command run.

Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC           
PyCon TX 2006        

More information about the Python-list mailing list