I would like to avoid cluttering my working directory with Python bytecode files *.pyc. Python 3.2+ uses a subdirectory called __pycache__for this purpose.
*.pyc
__pycache__
Since many of the projects I'm working on are Python 2.7, I wonder if there are any workarounds or utilities that can allow me to implement this behavior in my case?
You can try the option -Bfor Python:
-B
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x
So, you can run python -B test.pyor install PYTHONDONTWRITEBYTECODEaccordingly.
python -B test.py
PYTHONDONTWRITEBYTECODE