A. Innokentiev A. Innokentiev - 1 year ago 81
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?

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download