>>>mylist
[<code object ? at 0xb75df650, file "D:\python24\lib\site-packages\py2exe\boot_common.py", line 44>, <code object ? at 0xb75df698, file "<install zipextimporter>", line 1>, <code object ? at 0xb75f4ad0, file "****.py", line 2>]
import dis as pydis
import types
code = None
def read(filename):
f = open(filename)
content = f.read()
global code
code = compile(content, filename, 'exec')
f.close()
def find_code(code, name):
for item in code.co_consts:
if isinstance(item, types.CodeType):
if item.co_name == name:
return item
return None
def dis(code_name=None):
if code_name is None:
co = code
pydis.dis(co)
return co
names = code_name.split(".")
co = code
for name in names:
co = find_code(co, name)
if not co:
print '%s is not a valid name' % code_name
if co:
print (" byte code for %s " % code_name).center(60, '*')
pydis.dis(co)
>>>mylist[2].co_consts:
(1, None, ('gdi',), ('EnumProcesses',), ('Button',), ('Editbox',), ('Textin',), ('LOWORD', 'HIWORD', 'RGB', 'RECT'), ('Msg',), ('Listview',), ('Listbox',), ('Combobox',), ('Checkbox',), ('Radiobox',), ('Treeview',), ('StaticText',), ('Groupbox',), ('ContextMenu',), ('Menu',), ('SystemCursor',), ('GetVirtualScreenSize',), ('static',), ('Queue',), ('latin_1', 'gbk', 'utf_8', 'ascii', 'gb2312', 'gb18030'), ('StringIO',), ('dbapi2',), ('WinExec',), ('CF_TEXT', 'GHND'), 'Display_REG_Dialog', <code object Display_REG_Dialog at 0xb7cc9f50, file "****.py", line 50>, 'Display_INPUT_Dialog', <code object Display_INPUT_Dialog at 0xb7cd7188, file "****.py", line 96>, 'Display_INPUT_TIME_Dialog', <code object Display_INPUT_TIME_Dialog at 0xb7cd7380, file "****.py", line 134>, 'Setup_Find_Dialog', <code object Setup_Find_Dialog at 0xb7cd7530, file "****.py", line 168>, 'Get_yo2_user_Dialog', <code object Get_yo2_user_Dialog at 0xb7cd7770, file "****.py", line 209>, 'Edit_User_Dialog', <code object Edit_User_Dialog at 0xb7cd79b0, file "****.py", line 279>, 'Add_User_Dialog', <code object Add_User_Dialog at 0xb7cd7d10, file "****.py", line 332>, 'Add_Cate_Dialog', <code object Add_Cate_Dialog at 0xb7cd7f50, file "****.py", line 546>, 'Get_Pic_Dialog', <code object Get_Pic_Dialog at 0xb7cdd260, file "****.py", line 602>, 'Get_MPic_Dialog', <code object Get_MPic_Dialog at 0xb7cdd530, file "****.py", line 934>, 'Select_ExportType_Dialog', <code object Select_ExportType_Dialog at 0xb7cdd9b0, file "****.py", line 1276>, 'Setup_PROXY_Dialog', <code object Setup_PROXY_Dialog at 0xb7cddad0, file "****.py", line 1412>, 'Update_Dialog', <code object Update_Dialog at 0xb7cddba8, file "****.py", line 1564>, 'MyWindow', <code object MyWindow at 0xb7cef2f0, file "****.py", line 1698>, '')