def warnings_to_stdout():
 showwarning_orig = warnings.showwarning
 def showwarning(msg, cat, fname, lno, file=None, line=0):
  showwarning_orig(msg, cat, os.path.basename(fname), line, sys.stdout)
 warnings.showwarning = showwarning

def warnings_to_stdout ( ) : showwarning_orig = warnings . showwarning def showwarning ( msg , cat , fname , lno , file = None , line = 0 ) : showwarning_orig ( msg , cat , os . path . basename ( fname ) , line , sys . stdout ) warnings . showwarning = showwarning
redirect all warnings to stdout .