株式市場 ― 東証2部とマザーズ、低位株 

3377 アイケイコーポレーション ― 高値で149,000円を超えれば、上げ基調入りと判断することになる。


[2008/01/08 18:48] 株式市場 | TB(0) | CM(0)

商品先物 ― 東京白金(参考)、東京ガソリン(参考) 

(私はこれらの銘柄を取引していない。)

東京白金 ― 押しを確認した。買い入れが面白い。

東京ガソリン ― 多分押し目である。確認後には買いが面白い。ただし、先限で67920を下抜くと、下げ転換となるだろう。


[2008/01/08 17:23] 商品先物 | TB(0) | CM(0)

Python ― Hello, world! 

もちろん、Pythonの入門者 ― というより、プログラミングの入門者かもしれない ― として、私も各種入門書の不親切さに頭を悩ませる1人であるので、PythonでのHello, world!経験にここでこだわってみたい。

コマンドプロンプトを起動して、「python」と打ちこむと、「python.exe」が入っているフォルダがpath環境変数に設定されていれば、コマンドプロンプト画面に「>>>」が現われて、ユーザーからのpython構文入力を受け付ける。pythonから抜けるには、「exit()」を使う。

コマンドプロンプトでの「python」でpython.exeが起動しなければ、path環境変数にpython.exeを登録しなくちゃいけない。コマンドプロンプトでは、「path <python.exeの入っているフォルダ>;%path%」で一時登録できる。私はD:\Python25にpython.exeを置いているので、

C:\>path D:\Python25;%path%
で一時登録した。

次に、IDLEでも何でもいいけど、エディタを起動する。IDLEを使う場合には、FileメニューからNew Windowを選択すると、新しいファイルを編集するための窓が現れるので、そこに次の1行

print 'Hello, world!'
を記述して、「HelloWorld.py」あたりの適当な名前でどこかに保存する。私はH:\に保存した。

後は、次のような手順でHelloWorld.pyを実行する。

C:\>cd /d H:\
H:\>python HelloWorld.py
Hello, world!

とりあえず一件落着といいたいところだけど、「これをどうやってPythonをインストールしていない環境で実行するの?」という疑問が頭から離れない。

調べると、py2exeというのがあったので、Python 2.5用のpy2exeを入手して、インストールした。

ここでしばらく試行錯誤して、

from distutils.core import setup
import py2exe
setup(console=['HelloWorld.py'])
という内容のファイルを作り、「hws.py」という名前で保存し、コマンドプロンプトから、「python hws.py py2exe」と打ちこんでやると、長いメッセージ
H:\>python hws.py py2exe
running py2exe
creating H:\build
creating H:\build\bdist.win32
creating H:\build\bdist.win32\winexe
creating H:\build\bdist.win32\winexe\collect-2.5
creating H:\build\bdist.win32\winexe\bundle-2.5
creating H:\build\bdist.win32\winexe\temp
creating H:\dist
*** searching for required modules ***
*** parsing results ***
creating python loader for extension 'unicodedata'
creating python loader for extension 'bz2'
*** finding dlls needed ***
*** create binaries ***
*** byte compile python files ***
byte-compiling D:\Python25\lib\StringIO.py to StringIO.pyc
byte-compiling D:\Python25\lib\UserDict.py to UserDict.pyc
byte-compiling D:\Python25\lib\atexit.py to atexit.pyc
中略
byte-compiling D:\Python25\lib\warnings.py to warnings.pyc
byte-compiling H:\build\bdist.win32\winexe\temp\bz2.py to bz2.pyc
byte-compiling H:\build\bdist.win32\winexe\temp\unicodedata.py to unicodedata.pyc
*** copy extensions ***
copying D:\Python25\DLLs\bz2.pyd -> H:\dist
copying D:\Python25\DLLs\unicodedata.pyd -> H:\dist
*** copy dlls ***
copying D:\Python25\python25.dll -> H:\dist
setting sys.winver for 'H:\dist\python25.dll' to 'py2exe'
copying D:\Python25\w9xpopen.exe -> H:\dist
copying D:\Python25\MSVCR71.dll -> H:\dist
copying D:\Python25\lib\site-packages\py2exe\run.exe -> H:\dist\HelloWorld.exe

*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included,
you may or may not need to distribute them.

Make sure you have the license if you distribute any of them, and
make sure you don't distribute files belonging to the operating system.

   ADVAPI32.dll - C:\WINDOWS\system32\ADVAPI32.dll
   USER32.dll - C:\WINDOWS\system32\USER32.dll
   SHELL32.dll - C:\WINDOWS\system32\SHELL32.dll
   KERNEL32.dll - C:\WINDOWS\system32\KERNEL32.dll
が現われて、コンパイルが終了し、HelloWorld.exeが作られていて、実行に必要なライブラリと一緒にH:\distに入っているはず。
H:\>cd dist
H:\dist>dir
 ドライブ H のボリューム ラベルがありません。
 ボリューム シリアル番号は 40A6-9A89 です

 H:\dist のディレクトリ

2008/01/07  13:05    <DIR>          .
2008/01/07  13:05    <DIR>          ..
2007/04/18  08:51            77,824 bz2.pyd
2008/01/07  13:05            15,872 HelloWorld.exe
2008/01/07  13:05           710,503 library.zip
2006/07/11  18:35           348,160 MSVCR71.dll
2007/04/18  08:51         2,113,536 python25.dll
2007/04/18  08:51           475,136 unicodedata.pyd
2007/04/18  08:51             4,608 w9xpopen.exe
               7 個のファイル           3,745,639 バイト
               2 個のディレクトリ  146,065,920,000 バイトの空き領域
H:\dist>HelloWorld.exe
Hello, world!

これでようやく一件落着。


[2008/01/08 09:18] Python | TB(0) | CM(0)