On Mon, Jun 9, 2008 at 6:01 PM, <[EMAIL PROTECTED]> wrote: > Hello all, > > New user to python. I can write to a file, however, I would like to > do both...whatever I do on the screen, I'd like to write it to a file. > > any pointers on where I can find this info. > > thanks, >
This code has one really significant problem in that it opens the file each time it is called but it gives a bit of an idea about what you can do. [EMAIL PROTECTED]) python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:16) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> def myprintandwrite(outstr): ... f = open('out.txt', 'w') ... f.write(outstr) ... print outstr ... >>> myprintandwrite('this is a test') this is a test >>> ^D ([EMAIL PROTECTED]) cat out.txt this is a test ([EMAIL PROTECTED]) -- Stand Fast, tjg.
-- http://mail.python.org/mailman/listinfo/python-list