Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to debug python code?

Reply
Thread Tools

How to debug python code?

 
 
sushant.sirsikar@gmail.com
Guest
Posts: n/a
 
      03-31-2006
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

 
Reply With Quote
 
 
 
 
ravi.annaswamy@gmail.com
Guest
Posts: n/a
 
      03-31-2006
Here is an outstandingly well written article, with examples, from
Stephen Ferg:

http://www.ferg.org/papers/debugging_in_python.html

Ravi

 
Reply With Quote
 
 
 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      03-31-2006
On 30 Mar 2006 21:18:50 -0800, http://www.velocityreviews.com/forums/(E-Mail Removed) 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 <G>)

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).
--
> ================================================== ============ <
> (E-Mail Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> (E-Mail Removed) | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <

 
Reply With Quote
 
bruno at modulix
Guest
Posts: n/a
 
      03-31-2006
(E-Mail Removed) 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 '(E-Mail Removed)'.split('@')])"
 
Reply With Quote
 
Ravi Teja
Guest
Posts: n/a
 
      03-31-2006
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.

 
Reply With Quote
 
Kent Johnson
Guest
Posts: n/a
 
      03-31-2006
(E-Mail Removed) 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
 
Reply With Quote
 
Thomas Guettler
Guest
Posts: n/a
 
      03-31-2006
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: (E-Mail Removed)

 
Reply With Quote
 
Grant Edwards
Guest
Posts: n/a
 
      03-31-2006
On 2006-03-31, (E-Mail Removed) <(E-Mail Removed)> 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
 
Reply With Quote
 
R. Bernstein
Guest
Posts: n/a
 
      03-31-2006
(E-Mail Removed) 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.
 
Reply With Quote
 
R. Bernstein
Guest
Posts: n/a
 
      03-31-2006
Dennis Lee Bieber <(E-Mail Removed)> writes:

> On 30 Mar 2006 21:18:50 -0800, (E-Mail Removed) 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 <G>)


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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
debug="false" in web.config and <%@ debug="true" ...%> in aspx file => true or false? André ASP .Net 3 08-28-2006 12:02 PM
Config Mgr Debug/Release and Web.config Compilation debug=true RonL ASP .Net 0 04-08-2006 03:50 PM
Debug (DLL MFC) -> Debug (Static MFC) ringos75 C++ 0 04-14-2005 01:50 PM
[Howto] Compiling debug Python extensions for non-debug Python Mike C. Fletcher Python 3 10-12-2003 09:37 PM



Advertisments