the-generalist.com

  • Increase font size
  • Default font size
  • Decrease font size
joomla templates, wordpress themes, drupal, datalife engine, graphics, seo,
Home

Advanced Python Debugging Features with PyDev for Eclipse

E-mail Print PDF

I used to think that the debugging options were very limited while coding in Python. Eventually, I discovered that Eclipse with PyDev offers some more advanced functionality. Here's a couple debugging features you should try if you haven't already.

Conditional Breakpoints

Conditional breakpoints can make a huge difference in debugging your project. Say you're running this loop:

for x in range(1, 1000):
    foo(x)

Let's assume that every time you evaluate foo(x) when x = 537 it throws an exception, but it only does this when you run the loop. Set a breakpoint on foo(x), right click on it and hit advanced. Check the conditional breakpoint option and enter in the comparison you want to stop on. For instance you could enter x == 537. Start your program in debug mode. Now when you hit that breakpoint and x is 537 you'll break and can step through your code. If x is any other value, the breakpoint will be ignored.

Expressions Window

When you're stopped and stepping through code, you can use the Expressions window to evaluate functions or variables. Just paste what you want to evaluate into the column on the left and the value will be put on the right. Open the Expressions window by clicking Windows->Show View->Expressions. For instance say you have an if statement if myfunc(x) == otherfunc(y):. If you're not used to debugging you might put some print statements or temp variables in to help you find out what those functions are returning. Instead just put x, myfunc(x), y, and otherfunc(y) into the watch list and you can see all the needed values. Remember to set a breakpoint on your if statement so execution will stop and you can see your values.

You should try these debugging features. The more tools you have in your debugging toolbox, the quicker you can solve issues.

Last Updated on Thursday, 07 July 2011 15:01  

Comments  

 
0 #5 Candelaria 2017-09-09 10:25
I visited vario?s web sites ?ut the audio feature
for audio songs existing ?t this web pag? is r?ally
superb.
Quote
 
 
0 #4 Hildegard 2017-08-09 03:12
I was real pleased too find this site on bing, just what I was looking for .
D likewise saved to my bookmarks .
Quote
 
 
0 #3 Phyllis 2017-06-01 05:33
Hey there! This is kind of off topic buut I need some help from an established blog.
Is it hard to set up your own blog? Im not very techincal but I can figure things out pretty fast.
Im thinking about ceating my own but Im not sure where to begin. Do you have any tis or suggestions?
Appreciate it
Quote
 
 
0 #2 url 2017-03-05 22:42
? Un videogame de consolas que merece la pena empero dewspues
de todo resulta algo aburrido

Chekea y ademas navega por mi websiteXD url: http://ensconce.net/__media__/js/netsoltrademark.php?d=trucoteca.com
Quote
 
 
0 #1 videojuegos trucos 2017-02-18 05:16
? Un juego que divierte empezando desde el primerisimo punto a pesar de eso
que nos deja con ansias de algo mas

Hecha un ojo y navega por mi pageXD videojuegos trucos: http://www.hollywoodstudiomuseum.com/__media__/js/netsoltrademark.php?d=trucoteca.com
Quote
 

Add comment


Security code
Refresh

Main Menu