Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- def sprint(mytext, outfile=None):
- if outfile is None: out = sys.stdout
- else: out = open(outfile, 'w')
- try: # do some stuff
- out.write(mytext + '\n') # ...
- out.flush() #flush buffers
- finally:
- if outfile is not None: out.close()
- sprint('test') #write to screen
- sprint('test', 'test.log') #write to log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement