Anastasios Hatzis wrote: > Hi folks, > > how can I prevent Python from adding or using *.pyc files if executing a > Python module? I have the strong feeling that the interpreter uses > out-dated pyc file instead more recent py files. At least I already had > some cases where application behaviour changed only by removing the > *.pyc files from the app directory, and in all these cases I interpreted > the difference in code changes I already saved in py files but which had > no effect before removing their pyc versions. I'm not very happy on > deleting pyc files before each execution. > > I know there is an -o option for turning on optimization (pyo). In doc I > could not found a hint to an option to turn off pyc compilation -- or at > least forcing the interpreter to use py files only. > > I'm working with Python 2.4.2 on WinXP, Eclipse 3.2 with PyDev 1.2.2 > > Thanks for your help! > > Anastasios
The interpeter will always use the newer .py files in preference to older.pyc files, overwriting the .pyc files with newer versions. However, if your interpreter is re-importing a module without either re-starting (the interpreter) or reloading()'ing the module, it will use the loaded version in the sys.modules cache. This used to happen in IDLE before it was given the ability to run the interpreter in a separate subprocess. Now it automatically restarts the interpreter. I don't know whether Eclipse has this problem but it might. There are at least three ways of dealing with this: 1) Restart the interpreter (manually or through some IDE option), 2) call reload() on your modules, or 3) del the modules from sys.modules before re-importing them. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list