Generate .pyc from Python AST?

后端 未结 2 441
情深已故
情深已故 2021-02-05 17:09

How would I generate a .pyc file from a Python AST such that I could import the file from Python?

I\'ve used compile to create a code object, then written t

2条回答
  •  我寻月下人不归
    2021-02-05 17:19

    The compile standard function provides this function for both Python 2.x and Python 3.x. However, you will find that the AST representation between 2.x and 3.x is quite different, so be prepared for that.

提交回复
热议问题