Possible Duplicate:
Way to have compiled python files in a separate folder?
When python compiles modules to bytecode, it produces .pyc files from your .py files.
My question is, is it possible to have these .pyc files written to a different directory than where the module resides?
For example, I have a large directory of modules. Rather than having it littered with .pyc files, I would like to keep my source code in the directory and have a subdirectory like "bytecode" where all of the .pyc are stored.
Is this possible?
This is answered in "Way to have compiled python files in a seperate folder?"
Short answer: No – unless you're running Python 3.2 or later – see here.
To clarify: Before 3.2, you can compile bytecode and put it elsewhere as per Brian R. Bondy's suggestion, but unless you actually run it from there (and not from the folder you want to keep pristine) Python will still output bytecode where the .py files are.