On Tue, Jan 4, 2011 at 5:26 PM, Alex Hall <mehg...@gmail.com> wrote: > Hi all, > I am coming along quite nicely with Solitaire (sans graphics). > However, I am getting some odd behavior, and I would like to see what > is calling what so I can see where things are going wrong. It is not > causing an error to print a traceback, but it is not doing what I > expected at all. I tried the pdb module, but I am running a wx program > so it is not helping. I tried: > python -m pdb c:\prog\solitaire\game.py > > It gave me a prompt after my imports, so I typed "continue", and then > I saw nothing except the errors I knew I would get when I > intentionally hit some wrong keys.
typing continue in pdb is just the command to keep going until it runs into program end (or uncaught exception). There are a lot more commands available though, and they're very powerful. You can use 'next' or 'step' to slowly go through your program, 'where' to print a stack trace, and 'print' to display the value of any expression in the current context. You can also set a "breakpoint" at a specific line with the break command. When you type continue, execution will proceed until it hits a breakpoint. You can even specify a list of commands to be executed when the breakpoint is hit. Commonly, you set breakpoints at places where you expect the bug to manifest, type continue, and when one hits you slowly step through code, carefully examine values of variables, get a sense of what's really going on. > However, the behavior I was hoping > to track triggers nothing, and pdb said nothing else until I closed > the wx window. Is there a way to constantly track the stack of calls, > preferably with arguments? TIA. > There's also the backtrace module, but pdb should be all you need. I suggest you check the documentation for both of them, a quick google should do. Hugo _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor