Re: How to debug python code?
I don't have an example, but what I do is insert: import pdb pdb.set_trace() before the code that I think is causing the problem (or that the traceback barfed at). Then hit 'l' (lowercase L) to get a list of the code which is being executed. Use 'p' to look at variables. eg p some_local Use 'n' to execute the current line of code (doesn't follow method or function calls) Use 's' to step through code, including following function and method calls. Finally, 'c' to continue execution as normal. There are other options, but that should get you started. And look at the article linked elsewhere in this thread. pdb - because fencing off Alaska is too damn slow, binary search or not. jtm -- http://mail.python.org/mailman/listinfo/python-list
Re: How to debug python code?
Dennis Lee Bieber <[EMAIL PROTECTED]> writes: > My typical debugging technique is the infamous "wolf fence" (there's > one wolf in Alaska, how do you find it? First build a fence down the > middle of the state, wait for the wolf to howl, determine which side of > the fence it is on. Repeat process on that side only, until you get to > the point where you can see the wolf). In other words; put in a few > "print" statements until you find the statement that is failing (then > maybe work backwords from the "tracks" to find out where the wolf/bug > comes from). I think the advantage of this method is that one has to become clear what the state of the program should look like. For the same reason, unit tests may help to develop a proper specification of the task of a module. However, pdb's port mortem debugging can be helpful when a program takes a lot of time to hit the error, and a large amount of data is in play, for example for numerical computations. Johannes -- http://mail.python.org/mailman/listinfo/python-list
Re: How to debug python code?
[EMAIL PROTECTED] wrote: > hi, >I am new to Python programming.I am not getting exactly pdb.Can > anyone tell me effective way to debug python code? >Please give me any example. >Looking for responce. >Thank You. > Sushant If you are having issues you also might want to try: http://pychecker.sourceforge.net/ and see if it finds your problem. You might get lucky. Or just make the bigger install: http://stani.be/python/spe/blog/ that one already includes pychecker and a python debugger. Sorry for the noise if you were just looking for instructions for pdb. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to debug python code?
Dennis Lee Bieber <[EMAIL PROTECTED]> writes: > On 30 Mar 2006 21:18:50 -0800, [EMAIL PROTECTED] declaimed the > following in comp.lang.python: > > > hi, > >I am new to Python programming.I am not getting exactly pdb.Can > > anyone tell me effective way to debug python code? > > I think I toyed with pdb back around 1993... Never needed it... > > Of course, with so many different languages and debuggers in my > life, I've never found time to master any but the old VMS debugger > (which is nothing more than a very complex error handler ) That's one reason why in my bash and GNU make debugger (and in extending pdb), I've stuck to the gdb command set: the effort that is spent mastering gdb can be transfered in the GNU Make, Bash, *AND* Python debuggers. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to debug python code?
[EMAIL PROTECTED] writes: > hi, >I am new to Python programming.I am not getting exactly pdb.Can > anyone tell me effective way to debug python code? >Please give me any example. >Looking for responce. >Thank You. > Sushant Well, I guess (in addition to the other good suggestions in this thread) this is an obvious place to plug pydb http://bashdb.sourceforge.net/pydb If you are using pdb, I think you'll find pydb, um, better. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to debug python code?
On 2006-03-31, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >I am new to Python programming.I am not getting exactly pdb.Can > anyone tell me effective way to debug python code? 1) Read your code. Think. 2) Add some "print" statements. 3) goto 1) -- Grant Edwards grante Yow! Where's th' DAFFY at DUCK EXHIBIT?? visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How to debug python code?
Am Thu, 30 Mar 2006 21:18:50 -0800 schrieb sushant.sirsikar: > hi, >I am new to Python programming.I am not getting exactly pdb.Can > anyone tell me effective way to debug python code? Hi, I try to debug the code while I type: Use "assert". Then if you get an AssertionError you can insert print statements or raise("var=%s var2=%s" % (var, var2)) to narrow down the problem. I never used pdb. HTH, Thomas -- Thomas Güttler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de Spam Catcher: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: How to debug python code?
[EMAIL PROTECTED] wrote: > hi, >I am new to Python programming.I am not getting exactly pdb.Can > anyone tell me effective way to debug python code? I too rely mostly on unit tests and print statements for debugging, but occasionally I use winpdb which is a pretty nice GUI debugger. http://www.digitalpeers.com/pythondebugger/ Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: How to debug python code?
1.) Print statements 2.) IDEs Most Python IDEs provide visual debuggers so that you don't have to use command line ones such as pdb. As with all languages that allow to be executated as a script as well, print statements usually get the job done quite well in most cases. Please read the Python FAQ (as you should for any new language you learn) in its entirety. http://www.python.org/doc/faq/ It answers your IDE question you posted in the other thread as well as many of your future questions quite well. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to debug python code?
[EMAIL PROTECTED] wrote: > hi, >I am new to Python programming.I am not getting exactly pdb.Can > anyone tell me effective way to debug python code? (automated) unit tests + print statements + the interactive shell are usually enough. I almost never used pdb in 5+ years of Python programming. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list
Re: How to debug python code?
Here is an outstandingly well written article, with examples, from Stephen Ferg: http://www.ferg.org/papers/debugging_in_python.html Ravi -- http://mail.python.org/mailman/listinfo/python-list
How to debug python code?
hi, I am new to Python programming.I am not getting exactly pdb.Can anyone tell me effective way to debug python code? Please give me any example. Looking for responce. Thank You. Sushant -- http://mail.python.org/mailman/listinfo/python-list