それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

dir() パッケージの中身を調べる

dir(name) を用いるとそのモジュールで利用している、変数名を調べられる

import sys

print dir(sys) #
#
#['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__', '__stdin__', '_
#_stdout__', '_current_frames', '_getframe', 'api_version', 'argv', 'builtin_module_names',
# 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dllhandle', 'exc_c
#lear', 'exc_info', 'exc_type', 'excepthook', 'exec_prefix', 'executable', 'exit', 'getchec
#kinterval', 'getdefaultencoding', 'getfilesystemencoding', 'getrecursionlimit', 'getrefcou
#nt', 'getwindowsversion', 'hexversion', 'last_type', 'last_value', 'maxint', 'maxunicode',
# 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix'
#, 'ps1', 'ps2', 'setcheckinterval', 'setprofile', 'setrecursionlimit', 'settrace', 'stderr
#', 'stdin', 'stdout', 'subversion', 'version', 'version_info', 'warnoptions', 'winver']

print dir()
# ['__builtins__', '__doc__', '__name__', 'sys']