Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - How to debug python code?

 
Thread Tools Search this Thread
Old 03-31-2006, 06:18 AM   #1
Default 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



sushant.sirsikar@gmail.com
  Reply With Quote
Old 03-31-2006, 06:53 AM   #2
ravi.annaswamy@gmail.com
 
Posts: n/a
Default 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



ravi.annaswamy@gmail.com
  Reply With Quote
Old 03-31-2006, 08:17 AM   #3
Dennis Lee Bieber
 
Posts: n/a
Default Re: How to debug python code?
On 30 Mar 2006 21:18:50 -0800, 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).
--
> ================================================== ============ <
> | Wulfraed Dennis Lee Bieber KD6MOG <
> | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <



Dennis Lee Bieber
  Reply With Quote
Old 03-31-2006, 09:11 AM   #4
bruno at modulix
 
Posts: n/a
Default Re: How to debug python code?
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 ''.split('@')])"


bruno at modulix
  Reply With Quote
Old 03-31-2006, 10:36 AM   #5
Ravi Teja
 
Posts: n/a
Default 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.



Ravi Teja
  Reply With Quote
Old 03-31-2006, 11:48 AM   #6
Kent Johnson
 
Posts: n/a
Default Re: How to debug python code?
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


Kent Johnson
  Reply With Quote
Old 03-31-2006, 02:50 PM   #7
Thomas Guettler
 
Posts: n/a
Default 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:



Thomas Guettler
  Reply With Quote
Old 03-31-2006, 04:30 PM   #8
Grant Edwards
 
Posts: n/a
Default Re: How to debug python code?
On 2006-03-31, <> 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


Grant Edwards
  Reply With Quote
Old 03-31-2006, 05:05 PM   #9
R. Bernstein
 
Posts: n/a
Default Re: How to debug python code?
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.


R. Bernstein
  Reply With Quote
Old 03-31-2006, 05:08 PM   #10
R. Bernstein
 
Posts: n/a
Default Re: How to debug python code?
Dennis Lee Bieber <> writes:

> On 30 Mar 2006 21:18:50 -0800, 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.


R. Bernstein
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Access HTML elements in code behind??? nedums_b Software 1 02-07-2008 07:15 PM
Code Monkey want MCTS, Code Monkey take exam Zimri MCTS 0 04-03-2007 10:57 PM
Circumvent Region Code hufaunder@yahoo.com DVD Video 11 01-29-2007 09:51 PM
.avi files giving region code error Craig Cameron DVD Video 2 03-07-2006 02:49 PM
Change region code and PAL to NTSC? Aloke Prasad DVD Video 0 02-26-2004 01:54 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46