Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dig into variables while debugging

I am currently debugging code using Python. I have not been using Python for a while. I put some breakpoints on a variable which is an integer. Let's say this variable is X = 10. How can I:

  • see what is in the variable? (I can highlight and a yellow case appears but if there are a lot of information it is not practical to display like this)
  • do some manipulation of the variable, for example I would like to do X+2 and get the result?
like image 505
pam Avatar asked May 31 '16 09:05

pam


1 Answers

As noted in the comments, there are many possible IDEs you can use with Python. The original question was specifically about Eclipse and so my answer focuses on a solution using that IDE. Other solutions are possible if you prefer a different environment...

First off, you need to sort out which plug-in you use for eclipse. You have a few options as you can see on the python wiki. It looks like PyDev is more popular, but you could pick others.

Assuming you go for PyDev, you can use the watch facility as described here to evaluate any expression. Alternatively you can use the console debugger to evaluate code directly in the debugger.

EDIT: As per the comments, you can also open the Expressions window using Window > Show View > Other > Debug > Expressions. This is the same window as used for the watch facility and the contents can be edited directly.

like image 114
Peter Brittain Avatar answered Oct 16 '22 12:10

Peter Brittain