I've been using Eclipse as my IDE for python programming, mostly because it's free. However, as far as I can tell, its debugger is not that great. All I ever get are notices of what line the error occurs on (and what the error type is) and, while this can often be useful, it could be a lot better. For example, I have a very hard time with recursion errors -- it tells me about the error over and over, to the point where it pushes my printouts out of readable range.

A friend has Director and has shown me that it has a neat feature called "step into the code" or something like that. Essentially you put a marker in your code and as it runs, output will automatically be printed on what the code is doing (e.g. changing a variable, calling a function, etc.) until it runs into the error.

Does anyone know of this kind of functionality existing for a python IDE? Or anything more helpful than Eclipse?

Recommended Answers

All 5 Replies

I have found some bugs just using the Python debugger module pdb:

# test the built-in Python Debugger (Pdb in the Python reference)
# at the debugger's '(Pdb)' prompt you can type  h  for help or
# more specifically use   h step  or   h next

import pdb

#help('pdb')

# once the '(Pdb)' prompt shows, you are in the debugger
# and you can trace through by entering:
#
# next (or n) which goes line by line and does not get
# into functions or into every iteration of a loop
#
# step (or s) which is more detailed and for instance
# loops through an entire range()
#
# so use next to get where you want to be and then use step,
# once you have all the details you need, use next again

pdb.set_trace()

# now you can test the following code

def hasCap(s):
    """returns True if the string s contains a capital letter"""
    for num in range(65, 91):
        capLetter = chr(num)
        if capLetter in s:
            return True
    return False

str1 = 'Only pick up strings without Capital letters!'
str2 = 'only pick up strings without capital letters!'

# test the function hasCap()
if hasCap(str1):
    print "str1 has a capital letter"
else:
    print "str1 has no capital letter"

if hasCap(str2):
    print "str2 has a capital letter"
else:
    print "str2 has no capital letter"
commented: very nice +8

If you use Windows OS, Pyscripter has a nice debugger that I use a lot.

Wow, thanks guys. That looks really helpful, sneekula.

Vegaseat -- unfortunately I use Macs. I do have Fusion and whatnot but would prefer to avoid Windows applications where possible. If sneekula's suggestion doesn't fully fit the bill I will give it a try though.

Winpdb is a Platform Independent Python Debugger free from:
http://www.winpdb.org/
Once you get used to the strange way to load source files via File/Launch the GUI based debugger is very powerful. It highlights the active line in the source code, and follows data in a Locals/Globals/Exceptions window and also keeps track of Threads and the Stack.

I use Winpdb (recommended by our science prof) and like the way it follows variable values in real time as you step thrugh the code. You are right, using File/Launch to open a Python source file is not very intuitive.

It installs as a winpdb.py (also compiled optimized winpdb.pyo) in C:\Python25\Lib\site-packages on my Windows Vista computer. Also needs wxPython installed to run.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.