nad at acm
Oct 22, 2010, 8:11 PM
Post #2 of 5
<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
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:].
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
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
and "foo" in sys.argv.
idle -d -s -r foo.py "Hello World"
Open a shell window, run a startup script, enable the debugger,
run foo.py, passing "foo.py" in sys.argv and "Hello World" in
echo "import sys; print sys.argv" | idle - "foobar"
Open a shell window, run the script piped in, passing '' in
and "foobar" in sys.argv.
> 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.
nad [at] acm