[Tutor] How to print on screen and to a file, meanwhile?
Kent Johnson
kent37 at tds.net
Fri Jan 21 04:53:33 CET 2005
The logging module is good for this. You can set it up to log to the screen and a file. You have to
do some setup and change your print statements to call a logger.
See this section of the docs and the one following for examples.
http://www.python.org/dev/doc/devel/lib/minimal-example.html
It's easier than it looks, you just have to take a little time to figure out how to set it up the
way you like it.
Kent
沈洁元 wrote:
> Hi, I'm now writing a simulation program in Python. Indeed, it's a
> time-wasting program, a complete simulation will last several days.
> Of course, the simulation result is easily stored in files, through file class
> of Python.
>
> Now, my partners require the simulation result to be printed on screen and to
> be stored in file as well, therefore they can monitor the result in time.
> I hope these two output method should be used in the mean time ------ not a
> 'print' + a 'file.write'. :)
>
> So what's the single method to hold this requirement? Wish it's quite basic.
> By the way, the platform is FreeBSD.
> Juan Shen
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list