11👍
✅
No, in fact, Python will use the .pyc
file preferably and only access the .py
file if it a) exists and b) is newer than the .pyc
file.
This allows you to distribute a Python app in compiled form without the source code (although it’s not much of a code “obfuscation” technique).
9👍
Nope, Python is (intentionally, see below) dumb about this! You can run
find . -name '*.pyc' -delete
from your project directory to get rid of old .pyc
files.
If you’re using git, you can set up a hook to do this automatically on checkout. Here’s a similar solution for Mercurial.
- There are errors when I install django by git?
- Install mysql-python return error in CentOs
- Using existing field values in django update query
- Using Django's built in web server in a production environment
- Using materialized views or alternatives in django
2👍
The thing you can do to prevent this is to start django with
python -B manage.py runserver
or to automate deletion of pyc, probably with clean_pyc from django-extensions
./manage.py clean_pyc
Source:stackexchange.com