Page 1 of 1

debugging python scripts

Posted: June 12th, 2011, 12:52 pm
by iinjdpa
Hello, I am a beginner with Python and I don't know how to debug in Golly. I try to use pdb and pdb.set_trace() but it seems not to work.

Re: debugging python scripts

Posted: June 13th, 2011, 7:51 pm
by Andrew
I don't think it makes sense to use pdb with Golly because you won't be able to enter any pdb commands (you don't have access to a command line). If you want to see a call trace at a particular point in your script code, insert a line like this:

Code: Select all

raise RuntimeError("foo")
If you want to see the traceback info without exiting the script then do this instead:

Code: Select all

try:
   raise RuntimeError("foo")
except:
   import sys
   import traceback
   exception, msg, tb = sys.exc_info()
   golly.note('\n'.join(traceback.format_exception(exception, msg, tb)))