user1176316 user1176316 - 1 year ago 61
Python Question

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
    and get the result?


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.