使用标志打开 Python IDLE
Open Python IDLE with flags
我目前正在学习 MIT 的 OpenCourseWare 主题 "Introduction to Electrical Engineering and Computer Science 1",并且正在学习 Signals 上的模块 class。
我在使用 class 中的绘图方法时遇到问题。课程 material 指出:
"Be sure to start idle with the -n flag, if you want to make plots of signals from inside idle."
这是我在编码教育中第一次遇到用标志启动程序。我想我理解它所包含的一般要点,并且已经使用 windows 命令提示符打开 IDLE。
然而,到目前为止我运气不好,尽管我有猜测,但我并不真正知道我在做什么。
有人能解释一下我究竟是如何做到这一点的,以及更一般地说,打开带有标志的程序是如何工作的吗?
我已经进行了一些 google/stack 搜索,但仅得出堆栈溢出 material 假设我在回答其他问题时正在寻找的知识或在编码函数的上下文中讨论标志的信息在 python 本身(myFlag=False 或其他)。
我正在使用 python 2.6.
非常感谢。如果这个问题很愚蠢或显而易见,我深表歉意,我对编码还很陌生。
idle 只是 OS 的另一个程序 运行。就像 grep 或 ls 可以有标志,所以可以空闲。标志只是让在命令行上解析参数变得更容易和更有效。在 macos hre 上是选项。 windows 会相似
└─╼ idle -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].
我目前正在学习 MIT 的 OpenCourseWare 主题 "Introduction to Electrical Engineering and Computer Science 1",并且正在学习 Signals 上的模块 class。
我在使用 class 中的绘图方法时遇到问题。课程 material 指出:
"Be sure to start idle with the -n flag, if you want to make plots of signals from inside idle."
这是我在编码教育中第一次遇到用标志启动程序。我想我理解它所包含的一般要点,并且已经使用 windows 命令提示符打开 IDLE。
然而,到目前为止我运气不好,尽管我有猜测,但我并不真正知道我在做什么。
有人能解释一下我究竟是如何做到这一点的,以及更一般地说,打开带有标志的程序是如何工作的吗?
我已经进行了一些 google/stack 搜索,但仅得出堆栈溢出 material 假设我在回答其他问题时正在寻找的知识或在编码函数的上下文中讨论标志的信息在 python 本身(myFlag=False 或其他)。
我正在使用 python 2.6.
非常感谢。如果这个问题很愚蠢或显而易见,我深表歉意,我对编码还很陌生。
idle 只是 OS 的另一个程序 运行。就像 grep 或 ls 可以有标志,所以可以空闲。标志只是让在命令行上解析参数变得更容易和更有效。在 macos hre 上是选项。 windows 会相似
└─╼ idle -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].