Py... is using the .pyc file even if I've edited the source!

Thomas Wouters thomas at xs4all.net
Sun May 21 18:29:24 EDT 2000


On Sun, May 21, 2000 at 09:18:25PM +0200, Dag Sunde wrote:

> Is it a way to force Python to skip generating the
> .pyc file for a module?

No, unless you approximate it using 'execfile' or some such. But in general
you shouldn't need to...

> If I'm editing my main-module and a submodule at the
> same time, edits in the sub-module is ignored after
> the first time I run the main module...

> ( I guess it caches the bytecode???)

It does cache bytecode, but it should throw away the old bytecode and
generate new code when the original .py file has been modified. Are you
perhaps not re-starting your python script, but re-importing the module ?
That doesn't work, a module is imported only once, and then kept in memory
for the duration. (Unless you delete the entry for the module in sys.modules)
If you want to re-import a module while your script is still running, use
'reload()'.

If you are restarting your script and it still executes the old code, make
sure your systems' clock isn't doing pogojumps...

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list