Redirecting Output : Sys : Buildin Module PYTHON TUTORIALS


PYTHON TUTORIALS » Buildin Module » Sys »

 

Redirecting Output


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 TUTORIALS

 Navioo Buildin Module
» Sys