Custom Search

Sunday, November 27, 2011

How to create .pyc file or Compile Python Code


import
py_compile
py_compile.compile("myfile.py")

There’s also a compileall module which can be used to compile all modules in an entire directory tree.You can also automatically compile all files in a directory or directories using the compileall module.

import compileall 
compileall.compile_dir("my_project_dir", force=1)

No comments:

Post a Comment