‘IronPython’ タグのついている投稿
IronPython Console をもっと便利に(TABによる補完とか)
- 2010/05/11
- murabe
- IronPython
IronPyhton の開発環境を構築しています。
お客様に .NET Framework 4.0 が必要な提案をしておりまして、しかも、コンパイルが必要な言語はイマイチ要件にあわない。初めは IronRuby でやろうかと思ったのですが、調べたところ日本語の扱いに不安がある。ここはそろそろ安定しているであろう IronPython かな?というわけ。
さて、本題。インタラクティブシェルを便利にする、ipy.exe おすすめの起動時オプションをご紹介。
どんなオプションがあるのかはこんな感じで確認できます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | C:\Users\murave>"C:\Program Files\IronPython 2.6 for .NET 4.0\ipy.exe" -? Usage: ipy.exe Usage: ipy [options] [file.py|- [arguments]] Options: -3 Warn about Python 3.x incompatibilities -c cmd Program passed in as string (terminates option list) -D Enable application debugging -E Ignore environment variables -h Display usage -i Inspect interactively after running script -m module run library module as a script -O generate optimized code -OO remove doc strings and apply -O optimizations -Q arg Division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew -s Don't add user site directory to sys.path -S Don't imply 'import site' on initialization -t Issue warnings about inconsistent tab usage -tt Issue errors for inconsistent tab usage -u Unbuffered stdout & stderr -v Verbose (trace import statements) (also PYTHONVERBOSE= x) -V Print the version number and exit -W arg Warning control (arg is action:message:category:module :lineno) -x Skip first line of the source -X:AutoIndent Enable auto-indenting in the REPL loop -X:ColorfulConsole Enable ColorfulConsole -X:CompilationThreshold The number of iterations before the interpreter starts compiling -X:Debug Enable application debugging (preferred over -D) -X:EnableProfiler Enables profiling support in the compiler -X:ExceptionDetail Enable ExceptionDetail mode -X:Frames Enable basic sys._getframe support -X:FullFrames Enable sys._getframe with access to locals -X:GCStress Specifies the GC stress level (the generation to colle ct each statement) -X:LightweightScopes Generate optimized scopes that can be garbage collecte d -X:MaxRecursion Set the maximum recursion level -X:MTA Run in multithreaded apartment -X:NoAdaptiveCompilation Disable adaptive compilation -X:PassExceptions Do not catch exceptions that are unhandled by script c ode -X:PrivateBinding Enable binding to private members -X:Python30 Enable available Python 3.0 features -X:ShowClrExceptions Display CLS Exception information -X:TabCompletion Enable TabCompletion mode -X:Tracing Enable support for tracing all methods even before sys .settrace is called Environment variables: IRONPYTHONPATH Path to search for module IRONPYTHONSTARTUP Startup module |
お勧めは、TABキーでのキーワードの補完が有効になる「-X:TabCompletion」、自動でインデントしてくれる「-X:AutoIndent」、コンソールがカラーになる「 -X:ColorfulConsole」あたり。昔はTabCompletion と AutoIndent は設定すると問題もあったのですが(TabCompletion では日本語が文字化けするとか)なおっているようです。
これらのオプション、3年前に買った『オープンソース×Windowsスクリプティング IronPythonの世界』(荒井 省三)という本で知ったのですが、いまだにこの本ぐらいしか参考書がないみたい。
私は、スタートメニューの IronPython Console のショートカットをコピーしてリンク先に上記のオプションを追加したショートカットを作ってます。便利ですよ。
切れちゃってますが、リンク先の内容は「”C:\Program Files\IronPython 2.6 for .NET 4.0\ipy.exe” -X:TabCompletion -X:AutoIndent -X:ColorfulConsole」です。ipy.exe の Path については調整してくださいね。
Popularity: 8% [?]

