compile python .py file without executing

前端 未结 6 1305
星月不相逢
星月不相逢 2020-12-04 17:55

Is there a way to compile a Python .py file from the command-line without executing it?

I am working with an application that stores its python exte

6条回答
  •  执笔经年
    2020-12-04 18:08

    I would say something like this, so you can compile it to your chosen location:

    import py_compile
    py_compile(filename+".py",wantedlocation+wantedname+".pyc")
    

    As I have now done in my Python project on github.com/lolexorg/Lolex-Tools

提交回复
热议问题