Lets say I have:
>>> def test(a):
>>> print a
Now, I want to explore see how test looks like in its compiled form.
>>> test.func_code.co_code
'|\x00\x00GHd\x00\x00S'
I can get the disassembled form using the dis module:
>>> import dis
>>> dis.dis(test)
2 0 LOAD_FAST 0 (a)
3 PRINT_ITEM
4 PRINT_NEWLINE
5 LOAD_CONST 0 (None)
8 RETURN_VALUE
Is there an opensource and maintained decompiler I could use to turn the bytecode back into readable python code?
update: thanks for suggesting decompile, but it's outdated (python2.3) and no one maintains it anymore. Is there anything for python2.5 or later?
UnPyc
http://sourceforge.net/projects/unpyc/
It is a maintained fork of the old decompyle updated to work with 2.5 and 2.6.