Python byte-code to source-code converter
A Python 2.7 byte-code decompiler, written in Python 2.7
Version 0.13, 2012-2-22
Note: this package is not likely to change, and has been largely superseded by: uncompyle6
uncompyle2 converts Python byte-code back into equivalent Python source. It accepts byte-code from CPython version 2.7 and runs on Python 2.7 only.
The generated source pretty prints docstrings, lists, tuples and hashes.
uncompyle2 may also verify the equivalence of the generated source by by compiling it and comparing both byte-codes.
This code is based on John Aycock’s generic small languages compiler spark and his prior work on a tool called decompyle. It was vastly improved by Hartmut Goebel.
decompiles Python byte-code into equivalent Python source
pretty-prints docstrings, hashes, lists and tuples
reads directly from .pyc/.pyo files, bulk-decompile whole directories
output may be written to file, a directory or to stdout
option for including byte-code disassembly into generated source
uncompyle2 -h # prints short usage uncompyle2 --help # prints long usage
Runs on Python 2.7 only and handles bytecodes from 2.5-2.7. For something that runs on Python 2.6, 2.7, 3.2. 3.3, 3.4 and 3.5 and handles bytecodes from 2.5-3.5, see uncompyle6.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.