How print every line of a python script as its being executed (including the console)?
问题 I'd like to print every line of python script as it's being executed, as well as the log from the console as every line is being executed. For example, for this script: import time print 'hello' time.sleep(3) print 'goodbye' I'd like it to generate the following in the console: line 1: import time line 2: print 'hello' hello line 3: time.sleep(3) line 4: print 'goodbye' goodbye See below for my attempt import subprocess as subp python_string = """ import sys import inspect class SetTrace