Not too sure how much this would help in debugging python scripts, but at least it tells you any syntax errors before a long script runs for an hour before throwing an error.
Here’s the code
# compile.py
import py_compile, sys
py_compile.compile(sys.argv[1])
Here’s a sample python script
# helloworld.py
print “Hello World!”
Here’s an example to compile it
$ python ./compile.py ./helloworld.py
Running this generates a bytecode file called helloworld.pyc which could be run
$ python ./helloworld.pyc
python could also be used with the flag “-O” for optimize generated bytecode
>>> exit()


Recent Comments