Roy said:
It has happened enough times to make us look for a solution. Which
means "more than once".
Maybe the solution is education, not a technical fix.
I've suspicious of technical fixes for developer problems, because in my
experience that strategy ends in a race to the bottom where you end up with
coding standards and procedures that assume everyone is a code monkey who
can barely spell PC. It doesn't protect the monkeys, because there is no
end to the ways they can screw up, while the competent developers suffer
under repressive, B&D procedures that hinder more than help.
YMMV.
I prefer to keep the .pyc files, and only remove them when necessary, rather
than to remove them whether it's necessary or not. It's not just because
I'm an arrogant SOB who expects my team of developers to know at least more
than me, therefore if I know enough to look for orphaned .pyc files so
should they. It's because I am a big believer that your development system
should be as close as possible to the eventual deployment system as is
practical. Your app will (probably) use .pyc files when it is deployed, so
you should do the same when developing. Otherwise you can get bugs in
deployment that you cannot reproduce in development because the
environments are different.
The performance hit is minimal.
I guess that depends on the size of your project and how much you care about
the start up time. But as general advice, no, it may not be minimal.
[...]
Another solution would be if there was a flag you could give to Python
to tell it, "Only import a .pyc if the corresponding .py file exists".
It's already checking to see if the .py is newer, so this wouldn't even
cost anything.
That's called "Python 3.3"