开发者

Reassembling Python bytecode to the original code?

开发者 https://www.devze.com 2022-12-18 09:07 出处:网络
This might be a silly question, but, given the output of, say.. >>> from dis import dis >>> def myfunc(x):

This might be a silly question, but, given the output of, say..

>>> from dis import dis
>>> def myfunc(x):
...     print x ** 2
... 
>>> dis(myfunc)
  2           0 LOAD_FAST                0 (x)
              3 LOAD_CONST               1 (2)
              6 BINARY_POWER        
              7 PRINT_ITEM          
              8 PRINT_NEWLINE    开发者_运维知识库   
              9 LOAD_CONST               0 (None)
             12 RETURN_VALUE        

..or a .pyc file - is it possible to reassembling this into a valid piece of Python source code? I.e where reassemble(dis(myfunc)) == "def reassembled_function(x):\n print x ** 2"

Not for any particular practical reason, I'm just curious if this is possible, or has been attempted..

Related

  • Free Python decompiler that is not an online service?


http://sourceforge.net/projects/decompyle/

0

精彩评论

暂无评论...
验证码 换一张
取 消