Is possibile to get the AST from a python code object?

Viewed 85

I know that's possible from a snippet of code in python to get its AST or its code object via compile().

I was wondering if it is possible to do the opposite: I have the code object(extracted by a .pyc file) and I was looking for the its AST.

1 Answers

No, unfortunately it is not possible to do by conventional methods unless the file that the code object created is still available in the path. There are tools like uncompyle6, which might help though.

Related