468,133 Members | 1,228 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

automatic debugger?

hi
is there something like an automatic debugger module available in
python? Say if i enable this auto debugger, it is able to run thru the
whole python program, print variable values at each point, or print
calls to functions..etc...just like the pdb module, but now it's
automatic.
thanks

Jun 26 '06 #1
2 1604
mi*******@hotmail.com writes:
is there something like an automatic debugger module available in
python? Say if i enable this auto debugger, it is able to run thru the
whole python program, print variable values at each point, or print
calls to functions..etc...just like the pdb module, but now it's
automatic.


Dunno about Python but www.askigor.com automatically finds
the bugs in C programs. It's amazing.
Jun 26 '06 #2
mi*******@hotmail.com writes:
hi
is there something like an automatic debugger module available in
python? Say if i enable this auto debugger, it is able to run thru the
whole python program, print variable values at each point, or print
calls to functions..etc...just like the pdb module, but now it's
automatic.
thanks
pydb (http://bashdb.sourceforge.net) has a linetrace option sort of
like what's done in POSIX shells.

Here's an example:

#!/usr/bin/python
"""Towers of Hanoi"""
import sys,os

def hanoi(n,a,b,c):
if n-1 0:
hanoi(n-1, a, c, b)
print "Move disk %s to %s" % (a, b)
if n-1 0:
hanoi(n-1, c, b, a)

i_args=len(sys.argv)
if i_args != 1 and i_args != 2:
print "*** Need number of disks or no parameter"
sys.exit(1)

n=3

if i_args 1:
try:
n = int(sys.argv[1])
except ValueError, msg:
print "** Expecting an integer, got: %s" % repr(sys.argv[1])
sys.exit(2)

if n < 1 or n 100:
print "*** number of disks should be between 1 and 100"
sys.exit(2)

hanoi(n, "a", "b", "c")
$ pydb --basename --trace hanoi.py
(hanoi.py:2):
+ """Towers of Hanoi"""
(hanoi.py:3):
+ import sys,os
(hanoi.py:5):
+ def hanoi(n,a,b,c):
(hanoi.py:12):
+ i_args=len(sys.argv)
(hanoi.py:13):
+ if i_args != 1 and i_args != 2:
(hanoi.py:17):
+ n=3
(hanoi.py:19):
+ if i_args 1:
(hanoi.py:26):
+ if n < 1 or n 100:
(hanoi.py:30):
+ hanoi(n, "a", "b", "c")
--Call--
(hanoi.py:5): hanoi
+ def hanoi(n,a,b,c):
(hanoi.py:6): hanoi
+ if n-1 0:
(hanoi.py:7): hanoi
+ hanoi(n-1, a, c, b)
--Call--
(hanoi.py:5): hanoi
+ def hanoi(n,a,b,c):
(hanoi.py:6): hanoi
+ if n-1 0:
(hanoi.py:7): hanoi
+ hanoi(n-1, a, c, b)
--Call--
(hanoi.py:5): hanoi
+ def hanoi(n,a,b,c):
(hanoi.py:6): hanoi
+ if n-1 0:
(hanoi.py:8): hanoi
+ print "Move disk %s to %s" % (a, b)
Move disk a to b
(hanoi.py:9): hanoi
+ if n-1 0:
--Return--
(hanoi.py:9): hanoi
+ if n-1 0:
(hanoi.py:8): hanoi
+ print "Move disk %s to %s" % (a, b)
Move disk a to c
(hanoi.py:9): hanoi
+ if n-1 0:
(hanoi.py:10): hanoi
+ hanoi(n-1, c, b, a)
--Call--
(hanoi.py:5): hanoi
+ def hanoi(n,a,b,c):
(hanoi.py:6): hanoi
+ if n-1 0:
(hanoi.py:8): hanoi
+ print "Move disk %s to %s" % (a, b)
Move disk b to c
(hanoi.py:9): hanoi
+ if n-1 0:
--Return--
(hanoi.py:9): hanoi
+ if n-1 0:
--Return--
(hanoi.py:10): hanoi
+ hanoi(n-1, c, b, a)
(hanoi.py:8): hanoi
+ print "Move disk %s to %s" % (a, b)
Move disk a to b
(hanoi.py:9): hanoi
+ if n-1 0:
(hanoi.py:10): hanoi
+ hanoi(n-1, c, b, a)
--Call--
(hanoi.py:5): hanoi
+ def hanoi(n,a,b,c):
(hanoi.py:6): hanoi
+ if n-1 0:
(hanoi.py:7): hanoi
+ hanoi(n-1, a, c, b)
--Call--
(hanoi.py:5): hanoi
+ def hanoi(n,a,b,c):
(hanoi.py:6): hanoi
+ if n-1 0:
(hanoi.py:8): hanoi
+ print "Move disk %s to %s" % (a, b)
Move disk c to a
(hanoi.py:9): hanoi
+ if n-1 0:
--Return--
(hanoi.py:9): hanoi
+ if n-1 0:
(hanoi.py:8): hanoi
+ print "Move disk %s to %s" % (a, b)
Move disk c to b
(hanoi.py:9): hanoi
+ if n-1 0:
(hanoi.py:10): hanoi
+ hanoi(n-1, c, b, a)
--Call--
(hanoi.py:5): hanoi
+ def hanoi(n,a,b,c):
(hanoi.py:6): hanoi
+ if n-1 0:
(hanoi.py:8): hanoi
+ print "Move disk %s to %s" % (a, b)
Move disk a to b
(hanoi.py:9): hanoi
+ if n-1 0:
--Return--
(hanoi.py:9): hanoi
+ if n-1 0:
--Return--
(hanoi.py:10): hanoi
+ hanoi(n-1, c, b, a)
--Return--
(hanoi.py:10): hanoi
+ hanoi(n-1, c, b, a)
--Return--
(hanoi.py:30):
+ hanoi(n, "a", "b", "c")
--Return--
(<string>:1):
+ (bdb.py:366): run
+ exec cmd in globals, locals
Jul 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Bryan Bullard | last post: by
1 post views Thread by Rhino | last post: by
1 post views Thread by Raghu Raman | last post: by
4 posts views Thread by daftspaniel | last post: by
58 posts views Thread by Jorge Peixoto de Morais Neto | last post: by
3 posts views Thread by myjish18 | last post: by
27 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.