In article <04a3c943-5aee-4248-9cb3-60ea42410...@j4g2000prm.googlegroups.com>, Roger Davis <r...@hawaii.edu> 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, n...@acm.org -- http://mail.python.org/mailman/listinfo/python-list