The above patch does the work of capturestdout also. Here is much cleaner fix.
def print_stats(): stats = hotshot.stats.load(temp.name) stats.strip_dirs() stats.sort_stats('time', 'calls') stats.print_stats(40) stats.print_callers()
x = '\n\ntook '+ str(stime) + ' seconds\n' x += capturestdout(print_stats)()
The above patch does the work of capturestdout also. Here is much cleaner fix.
def print_stats(): stats.load( temp.name) strip_dirs( ) sort_stats( 'time', 'calls') print_stats( 40) print_callers( )
stats = hotshot.
stats.
stats.
stats.
stats.
x = '\n\ntook '+ str(stime) + ' seconds\n' print_stats) ()
x += capturestdout(