Panda3D Manual: The Python DebuggerPython is a very powerful interactive and interpreted language. Python's development cycle is very fast. Often the most effective way to to debug is to output relevant information. Having said that, there are many ways to enhance productivity with knowledge of good debugging techniques.
Using python -i modePython programs may be developed and tested with the help of the interactive mode of the Python interpreter, which, allows program components to be debugged, traced, profiled, and tested interactively. When invoking python with -i, this ensures that an interactive session of python is invoked. With regards to Panda3D this requires a little explanation. Panda3D programs typically have a command called run() to start rendering, so here's one way to start an interactive session. On the command prompt type: python -i myPandaFile.py After Panda3D has loaded, make sure the command window has focus and type Ctrl-C. This will show a python prompt like so: >>> Now on the command prompt you can execute any python commands, related or unrelated to your Panda3D program. This is useful for looking at information at that specific point in time. You could even change that information for that running instance of the program. pdbPython offers hooks enabling interactive debugging. Module pdb supplies a simple text-mode interactive debugger. It supports setting (conditional) breakpoints and single stepping at the source line level, inspection of stack frames, source code listing, and evaluation of arbitrary Python code in the context of any stack frame. It also supports post-mortem debugging and can be called under program control. The debugger's prompt is "(Pdb) ". There are many ways to enter the debugger. Typical usage to run a program under control of the debugger is: >>> import pdb >>> import <mymodule> >>> pdb.run('mymodule.test()') > <string>(0)?() (Pdb) continue > <string>(1)?() (Pdb) continue NameError: 'spam' <string>(1)?() (Pdb)
© Carnegie Mellon University 2010 |