Make Python ignore .pyc files
Question: Is there a way to make Python ignore any .pyc files that are present and
always interpret all the code (including imported modules) directly? Google
hasn't turned up any answers, so I suspect not, but it seemed worth asking
just in case.

(Why do I want to do this? I have a large pipeline of Python scripts which are
run repeatedly over a cluster of a couple hundred computers. The Python
scripts themselves live on a shared NFS filesystem. Somehow, rarely, after
having been run hundreds of times over several hours, they will suddenly start
crashing with an error about not being able to import a module. Forcing the
regeneration of the .pyc file fixes the problem. I want, of course, to fix the
underlying causes, but in the meantime we also need the system to continue
running, so it seems like ignoring the .pyc files if possible would be a
reasonable workaround).

P.S. I'm using Python 2.5, so I can't use -B.


Answer: It's not exactly what you asked for, but would removing the existing .pyc
files and then not creating any more work for you? In that case, you could use
the -B option:

    
    
    >python --help
    usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
    Options and arguments (and corresponding environment variables):
    -B     : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x
    

