1011_wxy wrote:
Hi JM:
*python c.py > afile.log* could you pls give me the whole example?
I am so sorry that I am a beginner in Python.

Your module a and b that you cannot modify given your original description, are printing data using the print statement. That means these module only intend to print the data on the standard output (aka stdout, your screen by default).

If you want to print the data in a file, then you have to make stdout that file. 2 possible way have been provided:

1/ within the c.py file, redirect sys.stdout to a file (see Chris Rebert's answer) 2/ use the system command line to redirect stdout to a file. In any unix system, you can redirect stdout to a file( instead of the screen) that way:

   echo "Hello world" > afile.txt

It works for any command, including

   python c.py > afile.txt


That will execute you c.py file writing everything into afile.txt instead of your display.

JM
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to