Question:
I would like to get the bytecode of a Python module and save it to a pyc with marshal.
Example:
ABC
- test
- module
- t2
- mod2
So I would import abc.test.module and I would like to get the bytecode and so save a pyc of it from that.
Answer:
A good but discontinued tool is UnPyc (supports Python versions 2.5 and 2.6 ). There are reports that this decompiler can recover about 90% of the original file.
There is also Easy Python Decompiler which is based on two decompilers ( uncompyle2 and decompyle++ ). The interesting thing is that it supports from version 1.0 to 3.3 of Python.
Also pay attention to the py_compile
module.