Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

IDLE debugger questions

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


rbd at hawaii

Oct 22, 2010, 7:19 PM

Post #1 of 5 (741 views)
Permalink
IDLE debugger questions

Hi, I have some questions about the IDLE debugger. I am using the
2.6.6 bundle downloaded from python.org.

First, how do I debug a Python program that requires command-line
args? I usually run it with a command like

% test.py arg1 arg2 arg3

There seems to be practically no detailed IDLE debugger documentation
and I have been unable to figure out how to pass these arguments into
the debugger.

Second, some folk say you can set a breakpoint by right-clicking on
the desired line in the source window to get a popup menu. This does
not work for me on my MacBook (external 3-button USB mouse), it only
adds a line-break into the source code. Any suggestions?

Thanks!

Roger Davis
--
http://mail.python.org/mailman/listinfo/python-list


nad at acm

Oct 22, 2010, 8:11 PM

Post #2 of 5 (714 views)
Permalink
Re: IDLE debugger questions [In reply to]

In article
<04a3c943-5aee-4248-9cb3-60ea424108cb [at] j4g2000prm>,
Roger Davis <rbd [at] hawaii> wrote:
> Hi, I have some questions about the IDLE debugger. I am using the
> 2.6.6 bundle downloaded from python.org.
>
> First, how do I debug a Python program that requires command-line
> args? I usually run it with a command like
>
> % test.py arg1 arg2 arg3

One way would be to add some initialization test code to the main module
to set sys.argv. Another way is to call idle from the command line:

$ /usr/local/bin/idle2.6 -h

USAGE: idle [-deins] [-t title] [file]*
idle [-dns] [-t title] (-c cmd | -r file) [arg]*
idle [-dns] [-t title] - [arg]*

-h print this help message and exit
-n run IDLE without a subprocess (see Help/IDLE Help for
details)

The following options will override the IDLE 'settings' configuration:

-e open an edit window
-i open a shell window

The following options imply -i and will open a shell:

-c cmd run the command in a shell, or
-r file run script from file

-d enable the debugger
-s run $IDLESTARTUP or $PYTHONSTARTUP before anything else
-t title set title of shell window

A default edit window will be bypassed when -c, -r, or - are used.

[arg]* are passed to the command (-c) or script (-r) in sys.argv[1:].

Examples:

idle
Open an edit window or shell depending on IDLE's configuration.

idle foo.py foobar.py
Edit the files, also open a shell if configured to start with
shell.

idle -est "Baz" foo.py
Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell
window with the title "Baz".

idle -c "import sys; print sys.argv" "foo"
Open a shell window and run the command, passing "-c" in
sys.argv[0]
and "foo" in sys.argv[1].

idle -d -s -r foo.py "Hello World"
Open a shell window, run a startup script, enable the debugger,
and
run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in
sys.argv[1].

echo "import sys; print sys.argv" | idle - "foobar"
Open a shell window, run the script piped in, passing '' in
sys.argv[0]
and "foobar" in sys.argv[1].

> Second, some folk say you can set a breakpoint by right-clicking on
> the desired line in the source window to get a popup menu. This does
> not work for me on my MacBook (external 3-button USB mouse), it only
> adds a line-break into the source code. Any suggestions?

Right-click (control-click) menus currently don't work in IDLE on OS X.
I hope to get that fixed eventually.

--
Ned Deily,
nad [at] acm

--
http://mail.python.org/mailman/listinfo/python-list


rbd at hawaii

Oct 23, 2010, 8:29 AM

Post #3 of 5 (714 views)
Permalink
Re: IDLE debugger questions [In reply to]

Thanks for that info, Ned, I can now get the sys.argv[] list I need,
that's a big help! However, is there any other way to set a breakpoint
in idle that will work on Mac OS X, maybe entering a manual command
somewhere with a specified line number? Inability to set a breakpoint
is an absolute showstopper for me, the code I am trying to debug loops
way too much to be manually steppable in a human time frame.

I also spent a couple of hours trying to get ddd to work, and oddly
enough encountered a similar problem there. After downloading and
installing pydb I was able to get things to start up OK. You can set a
breakpoint, meaning that you can click on the source line and the
little stop sign icon pops up right there as expected, but when you
run the code the debugger just blows right by it like it's not even
there. Does anyone out there have a fix for this? It sounds like ddd
Python support is highly problematic at the moment, supposedly it
works only with pydb but pydb's author has apparently moved on to a
different debugger project (pydbgr?) that I suspect has little chance
of working with ddd just yet. If anyone has evidence to the contrary
please let me know!

Are there any Python debuggers with a decent GUI out there at all that
will work on a Mac with the following features: (i) ability to pass in
a sys.srgv[] list that the program would otherwise see without the
debugger, (ii) display local variables, (iii) single-step through the
source code, and (iv) set a breakpoint? I think I can live without
anything else for the moment.

Thanks!
--
http://mail.python.org/mailman/listinfo/python-list


nad at acm

Nov 13, 2010, 2:03 AM

Post #4 of 5 (692 views)
Permalink
Re: IDLE debugger questions [In reply to]

In article
<f710b476-ca92-414b-865b-feac70120114 [at] r31g2000prg>,
Roger Davis <rbd [at] hawaii> wrote:
> Thanks for that info, Ned, I can now get the sys.argv[] list I need,
> that's a big help! However, is there any other way to set a breakpoint
> in idle that will work on Mac OS X, maybe entering a manual command
> somewhere with a specified line number? Inability to set a breakpoint
> is an absolute showstopper for me, the code I am trying to debug loops
> way too much to be manually steppable in a human time frame.

Sorry about the long delay in replying. It turns out that IDLE's
breakpoint facility is currently unusable on OS X when Python Tkinter is
built with Aqua Tk, the default on OS X. The reason: IDLE implements
the Set and Clear Breakpoints menu options through a context popup menu
but the popup menus don't work with Aqua Tk. On other systems, the
popup menus are bound to the Right mouse button. But on OS X, there's
no guarantee that there is more than one button (the Left) and, even if
there is, the button bindings are different for Aqua Tk. The net effect
is that you can't make the popup menus appear with or without a
three-button mouse or equivalent. As far as I can tell, this has been
an issue ever since Python started using Aqua Tk on OS X instead of X11
Tk, many releases ago.

I've opened an issue for the problem and supplied a patch to have IDLE
use Control-Click for popups on OS X as is common in other applications.

http://bugs.python.org/issue10404

Thanks for calling this problem to our attention!

--
Ned Deily,
nad [at] acm

--
http://mail.python.org/mailman/listinfo/python-list


cbrown at cbrownsystems

Nov 13, 2010, 11:11 AM

Post #5 of 5 (689 views)
Permalink
Re: IDLE debugger questions [In reply to]

On Oct 23, 7:29 am, Roger Davis <r...@hawaii.edu> wrote:

<snip>

> Are there any Python debuggers with a decent GUI out there at all that
> will work on a Mac with the following features: (i) ability to pass in
> a sys.srgv[] list that the program would otherwise see without the
> debugger, (ii) display local variables, (iii) single-step through the
> source code, and (iv) set a breakpoint? I think I can live without
> anything else for the moment.
>

I'm very happy using the Eclipse IDE (available for Mac, PC and 'Nix)
with the pydev plug-in. It's free, well supported and well behaved,
and has all the debugging features you name and then some. It's also a
modern code editor with code-hinting, syntax highlighting, etc.

The only downside of Eclipse to me is its 'workspace' and 'project'
metaphors for file organization; which take a bit of getting used to,
particularly if you're used to just editing in a text editor, and then
running in Idle or a command line.

I still usually also have Idle open as well so I can test little code
snippets quickly and easily; but mostly I work in Eclipse.

Cheers - Chas
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.