Pythonメモ
OSはUbuntu 9.04
PythonはPython 2.6.2
2010年1月10日日曜日
オブジェクトを比較し -1, 0, 1 を返す
›
組み込み関数の cmp を使う # -*- coding: utf-8 -*- # 戻り値は数値 # x < y なら -1, x == y なら 0, x > y なら 1 i = cmp( "a" , "b" ...
2009年12月26日土曜日
ホームディレクトリを取得する
›
# -*- coding: utf-8 -*- import os.path import os hd = os.environ[ "HOME" ] hd = os.path.expanduser( "~" ) 詳細はドキ...
2009年12月22日火曜日
関数から関数名を文字列で取得する
›
# -*- coding: utf-8 -*- def func(): print "hello" # 関数オブジェクトから関数名を取得する s = func.__name__ import __main__ # モジュールオブジェ...
2009年12月20日日曜日
カーソルを変更する
›
# -*- coding: utf-8 -*- import gtk def widget_set_cursor(widget): # 標準のカーソル widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.TO...
2009年11月14日土曜日
MIMEタイプを取得する
›
mimetypes モジュールを使う # -*- coding: utf-8 -*- import mimetypes print mimetypes.guess_type( "test.py" ) 実行すると ('text...
›
ホーム
ウェブ バージョンを表示