Something like __pycache__ for Python 2.x?

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.

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?

+4
source share
1 answer

You can try the option -Bfor Python:

-B     : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x

So, you can run python -B test.pyor install PYTHONDONTWRITEBYTECODEaccordingly.

0
source

All Articles