fork download
  1. from __future__ import print_function
  2. import __builtin__
  3.  
  4. oldprint = __builtin__.print
  5.  
  6. def myprint(*args, **kwargs):
  7. oldprint('myprint', end='! ') # print to sys.stdout
  8. oldprint(*args, **kwargs)
  9.  
  10. __builtin__.print = myprint # monkey-patch, henceforth `print` refers to `myprint`
  11.  
  12. print('abc')
  13.  
  14. # note: it won't help you against `sys.stdout.write()`, `os.write()`, modules that don't use `print_function`, etc
Success #stdin #stdout 0.08s 10840KB
stdin
Standard input is empty
stdout
myprint! abc