I would like to avoid cluttering up my working directory with Python bytecode *.pyc
files. Python 3.2+ uses a subdirectory called __pycache__
for this purpose.
Since many of the projects I work on are Python 2.7, I'm wondering if there are any workarounds or utilities that can allow me to implement some similar behavior in my case?
__pycache__ is a directory that contains bytecode cache files that are automatically generated by python, namely compiled python, or . pyc , files.
__pycache__ is a folder containing Python 3 bytecode compiled and ready to be executed. I don't recommend routinely laboriously deleting these files or suppressing creation during development as it wastes your time.
__pycache__ is among the directories that shouldn't be pushed to remote repositories. Therefore, all you need to do is specify the directory in . gitignore file. Note that for Python projects in general, there are a lot more files that need to go into .
In the Project Tool Window , right-click a project or directory, where Python compiled files should be deleted from. On the context menu, choose Clean Python compiled files .
You can try the -B
option of Python:
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x
So, you can run python -B test.py
or set PYTHONDONTWRITEBYTECODE
appropriately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With