ziman@idefix:~ $ python Python 2.6.6 (r266:84292, Apr 20 2011, 11:58:30) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os, sys >>> fd = os.open('log.txt', os.O_RDWR) >>> os.dup2(fd, 1) >>> print "hello world" >>> exit() ziman@idefix:~ $ cat log.txt hello world ziman@idefix:~ $
logf = openfile("log.txt") # otvorit log os.dup2(logf.fd(), 1) # presmerovat stdout -> logf print "hello world"