Python debugging in Eclipse + PyDev

I try a couple of Eclipse + PyDev for some of my work. (Eclipse v3.5.0 + PyDev v1.5.6) I could not find a way to set all my variables to the PyDev console (Via the PyDev console → Console for the current active editor) I use simple code to describe the problem, When I step through the code, I don’t I can access my variable "x" from the console. This is viewed on the Variables tab, but this is not quite what I want.

Any help is appreciated.

See my screenshot for a better description:

alt text

EDIT:

Suppose by adding simple functionality, for example:

def myfunc(x): return x**x 

When I debug a function added to the code, I can easily access myfunc from the console. (Enter myfunc and it will be available after this automatic execution:

 >>> from part2.test import myfunc >>> myfunc 

Then, when I do myfunc (5), it acts the same as in the Python interpreter. It would be so useful to access variables in a similar way to debug my code. I have large arrays and I do various tests and operations during the debugging process. For example: get my x and execute x.sum (), later make x [:: 10] or transpose to work with other arrays, observe the results, experiment, etc.

Hope there will be a better solution.

+7
python eclipse pydev
source share
2 answers

Update:

In recent versions of PyDev, you can right-click a frame on the stack and select PyDev> Debug console so that the interactive console has more context-related features during a debugging session.


Unfortunately, the real interactive console, which will be the preferred way to play with the code (with code completion, etc. - http://pydev.org/manual_adv_interactive_console.html ) now has no connection with the debugging session (it is planned, but still not implemented).

However, with a “simpler” console, you can still interactively check and reproduce the variables available in the checkpoint area: http://pydev.org/manual_adv_debug_console.html (this is the same as you would have with pdb is just a matter of entering code in an accessible console after the breakpoint has been removed).

Greetings

Fabio

+8
source share

For this kind of search debugging, I like to use pdb, a debugger with batteries turned on. I have not used it inside PyDev, so I don’t know how all this will fit. I guess he will do what you expect. An example of its use:

 import pdb def myfunc(x): pdb.set_trace() return x**x 

This will cause a break just before the return statement is executed, and it will allow you to use the full Pythonic instructions to find out what happens. I use it as an interactive print report: setting the place where I want to dive, exploring the values ​​and calculating the results, as well as switching to them to observe how this happens. This may be a lazy way to debug, but sometimes you need more information before you can make less lazy decisions :-)

The page that I usually link to is in the Python Conquers Universe , which also links to several other sources of information.

+2
source share

All Articles