SHOW:
|
|
- or go back to the newest paste.
| 1 | import sys | |
| 2 | def sprint(mytext, outfile=None): | |
| 3 | if outfile is None: out = sys.stdout | |
| 4 | else: out = open(outfile, 'w') | |
| 5 | try: # do some stuff | |
| 6 | - | out.write(mytext + '\n') # ... |
| 6 | + | out.write(mytext + '\n') # ... |
| 7 | out.flush() #flush buffers | |
| 8 | finally: | |
| 9 | if outfile is not None: out.close() | |
| 10 | sprint('test') #write to screen
| |
| 11 | sprint('test', 'test.log') #write to log |