Link Python print stream into a file : Standard Redirect : Development PYTHON examples


PYTHON examples » Development » Standard Redirect »

 

Link Python print stream into a file


Link Python print stream into a file

import sys

print 'Dive in'
saveout = sys.stdout
fsock = open('out.log', 'w')
sys.stdout = fsock
print 'This message will be logged instead of displayed'
sys.stdout = saveout
fsock.close()


           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Development
» Standard Redirect