faqts : Computers : Programming : Languages : Python : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

41 of 65 people (63%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How can I decompile a python PYC file to see the source?

Aug 26th, 2007 00:58
shi woo, unknown unknown, Thomas Wouters, Erno Kuusela


You cannot. .pyc files are bytecode, and you can only disassemble them 
into a representation of bytecode. That's not as low-level as 
machine-code, but it's not Python code either ! See the 'dis' module on 
how to disassemble.
------------
try decompyle
(<URL:http://www.csr.uvic.ca/~aycock/python/content.html#decompyle>).
try depython
(<URL:http://www.depython.net).You can online test its function freely .
note the words of warning on the page:
| It's rather fragile, and dependent on what the Python bytecode
| compiler emits. I'm releasing it for demonstration and amusement
| purposes only.