view raw
A. Innokentiev A. Innokentiev - 11 months ago 40
Python Question

Removed .py files, compiled .pyc files and git - how to?

I have removed some files (
) from project and committed my changes. My teammate pulled changes and program exited with errors.

After some research we have found problem:
Git removed
files, but compiled
files remained and caused problems - program used old sources and get an errors.

files ignored in

What is the best solution to solve such problem?

UPDATE: I know how to ignore files - question not about it. Question is how to avoid situations described above?


You will simply have to go through and delete the .pyc files. The python interpreter is such that the .pyc files are always used unless the .py files are newer (in which case it recompiles the .pyc file).

A good solution is to include a cleaning step in your workflow that removes all .pyc files before running the program:

find . -name "*.pyc" -delete