A
Arnaud Delobelle
Hi all,
In Python 3, a function f's code object can be accessed via f.__code__.
I'm interested in getting a module's code object, i.e. the code that
is executed when the module is run. I don't think it's accessible via
the module object itself (although I would be glad if somebody proved
me wrong . In the marshal module docs [1] it is mentioned that:
"""
The marshal module exists mainly to support reading and writing the
“pseudo-compiled†code for Python modules of .pyc files.
"""
So it seems that the module's code object is marshalled into the .pyc
file - so there may be a way to unmarshal it - but I can't easily find
information about how to do this.
Is this a good lead, or is there another way to obtained a module's code object?
Thanks
In Python 3, a function f's code object can be accessed via f.__code__.
I'm interested in getting a module's code object, i.e. the code that
is executed when the module is run. I don't think it's accessible via
the module object itself (although I would be glad if somebody proved
me wrong . In the marshal module docs [1] it is mentioned that:
"""
The marshal module exists mainly to support reading and writing the
“pseudo-compiled†code for Python modules of .pyc files.
"""
So it seems that the module's code object is marshalled into the .pyc
file - so there may be a way to unmarshal it - but I can't easily find
information about how to do this.
Is this a good lead, or is there another way to obtained a module's code object?
Thanks