36

I'm debugging my Python code in Eclipse using the Pydev plugin. I'm able to open a Pydev console and it gives me two options: "Console for currently active editor" and "Python console". However none of them is useful to inspect current variable status after a breakpoint.

For example, the code stopped at a breakpoint and I want to inspect an "action" variable using the console. However my variables are not available. How can I do things like "dir(action)", etc? (even if it is not using a console).

James Blackburn
  • 4,492
  • 2
  • 27
  • 24
ricafeal
  • 14,169
  • 4
  • 19
  • 10
  • 8
    Jimmy Orr and SmileyChris answered this question below, make sure to give them mad props with a magic green check mark. – pokstad Feb 04 '10 at 20:50
  • Rupert bates has all you need. Set a breakpoint. Hit the debug button. type print("hello world") in the console and hit enter twice. basta, a working shell in the proper scope, with all the goodies of the eclipse debugger gratis. – tjb Aug 13 '11 at 17:25

5 Answers5

30

This feature is documented here:

http://pydev.org/manual_adv_debug_console.html

jimmyorr
  • 11,178
  • 7
  • 30
  • 21
  • 7
    In case anyone else stumbles over this old question, "Pydev extensions" has now been merged with the free version, so this functionality is available to everyone. – SmileyChris Jan 18 '10 at 04:04
  • 1
    +1 to SmileyChris, I have traveled back in time to read this post. Once in the debug perspective, you must press Enter twice in order to execute a command in the console. – pokstad Feb 04 '10 at 20:48
  • An extra note: the actions described must be executed in the Debug perspective. Trying to do so in the console view from other perspectives result in nothing. – Chuim Mar 19 '10 at 16:31
13

The console that opens in the debug perspective is in fact interactive, although it took me a while to realize it. You need to hit return twice after typing something and then it gets evaluated. More info on the Pydev site here: http://pydev.org/manual_adv_debug_console.html

Rupert Bates
  • 3,041
  • 27
  • 20
1

Double click on "action" or any other variable.

ctrl+shift+D

And if you're using watches, I cant imagine better interaction. You are able to see every change.

Chobicus
  • 2,024
  • 2
  • 17
  • 26
  • 1
    Thanks, but I imagined a better one: interactive console with visibility of the debugging scope. It is possible in other IDEs. – ricafeal Nov 07 '08 at 10:40
0

When I set a break point and hit F11 Eclipse launches the debugger and prompts to open the "Debug Perspective". You can then open the Window-->Show View --> Expressions which opens the expressions view, you can then right click in the Expressions view windows and choose "Add Watch Expression" to add any expression(such as dir) Conversely I was also able to type in dir(some expression) in the PyDev console and get the same effect. I'm using PyDev 1.4.6.2788

Abhijeet Patel
  • 6,562
  • 8
  • 50
  • 93
0

On a small monitor, you may not realize that the debug interactive console is different from the regular interactive console: it has a second command prompt at the bottom where you type, not at the top like the normal console.

Noumenon
  • 5,099
  • 4
  • 53
  • 73