debugging python scripts

For scripts to aid with computation or simulation in cellular automata.
Post Reply
User avatar
iinjdpa
Posts: 3
Joined: June 11th, 2011, 11:40 am

debugging python scripts

Post 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.
User avatar
Andrew
Moderator
Posts: 1065
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: debugging python scripts

Post 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)))
Use Glu or Glui to explore CA rules on non-periodic tilings: DominoLife and HatLife and SpectreLife
Post Reply