2017-12-07 11 views
0

私は現在、MITのOpenCourseWareの科目「電気工学とコンピュータサイエンス1」を受講しており、Signalsクラスのモジュールまであります。フラグ付きのPython IDLEを開く

私はクラスでプロット方法を使用する際に問題があります。教材の状態:

「アイドル状態からの信号をプロットするには、-nフラグを使用してアイドル状態を開始してください。

これは私がコーディング教育で初めて、フラッグ付きのプログラムを開始したことです。私はそれが必要とするものの一般的な要点を理解し、Windowsコマンドプロンプトを使用してIDLEを開いて遊んだと思う。

しかし、私は今まで運がなかったし、私の推測にもかかわらず、私が何をしているのか分からない。

誰かが私がこれをどのように正確に行うことができるのか、より一般的にはフラグ付きのオープニングプログラムがどのように機能するのかを説明できるでしょうか?

私はいくつかのGoogle /スタック検索を行ってきましたが、Python自体の関数をコーディングする文脈で、他の質問や情報に答えるために探している知識を前提にして、スタックオーバーフローマテリアルだけを考え出しました(myFlag = Falseまたは何でも)。

私はPython 2.6を使用しています。

事前に感謝します。疑問がばかげているか明白なことをお詫び申し上げます。

答えて

0

アイドルはOSによって実行される別のプログラムです。 grepやlsがフラグを持つことができるように、アイドル状態にすることができます。フラグは、コマンドラインでパラメータを解析するほうが簡単で効率的です。 on macos hreがオプションです。ウィンドウが似ている

└─╼ 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]. 
+0

これは非常に便利なので、コマンドプロンプトで何もしないでください。 – washboardalex

+0

btw、IDLEはかなり古い学校ですが、IPythonとJupyterは多くのPythonコーダーに好まれています。 – ShpielMeister

+0

はい、通常、私はAnacondaまたはEnthought CanopyとPythonのそれ以降のバージョンを使用します。コースは2011年からですので、プログラムによる時間旅行が必要でした... – washboardalex

関連する問題