Compiling *.py files
Question: I'm trying to compile python source files without success. According to
[documentation](https://docs.python.org/3.2/library/compileall.html),
**compileall.compile_dir** function has "**ddir** " parameter, which (I guess)
specifies the destination folder for .pyc files. I try to compile it with this
script:

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

but it doesn't work. I see output from terminal (compiling, listing etc.) but
pyc files are not generated. Anyone can help me understand where pyc files are
stored and how to change that default behavior?

Thanks


Answer: Check `__pycache__` directories. Since Python 3.2, the compiled files are
collected in `__pycache__` directories.

See [PEP 3147: PYC Repository Directories - What’s New In Python
3.2](https://docs.python.org/3/whatsnew/3.2.html?highlight=__pycache__#pep-3147-pyc-
repository-directories).

BTW, `ddir` is not destination directory. According to [the
documentation](https://docs.python.org/3/library/compileall.html#compileall.compile_dir):

> If _ddir_ is given, it is prepended to the path to each file being compiled
> for use in compilation time tracebacks, and is also compiled in to the byte-
> code file, where it will be used in tracebacks and other messages in cases
> where the source file does not exist at the time the byte-code file is
> executed.

