compileall.compile_file()
compileall.compile_file() is a Python function in the Compileall Module category. Compiles a single .py file to .pyc. The syntax is compileall.compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, invalidation_mode=None). Returns: Boolean. A typical example: compileall.compile_file("myscript.py", force=True). A close sibling is compileall.compile_dir(), which compiles all .py files in a directory to .pyc bytecode. A close sibling is compileall.compile_path(), which compiles all .py files on sys.path. More about this category: Bytecode compilation — compile_dir, compile_file, compile_path. Related Compileall Module entries: compileall.compile_dir(), compileall.compile_path(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try compileall.compile_file() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.