[Python-talk] Modules force recompilation?

bruce.labitt at autoliv.com bruce.labitt at autoliv.com
Fri Feb 5 11:58:45 EST 2010


kent3737 at gmail.com wrote on 02/04/2010 08:29:17 PM:

> On Thu, Feb 4, 2010 at 5:43 PM,  <bruce.labitt at autoliv.com> wrote:
> > I have created a couple modules(?) that have functions in them.  They 
are
> > spread across a couple of files.
> >
> > One thing that I don't know how to do gracefully, is to force a 
recompile
> > of a module to bytecode once I have editted the source file.
> >
> > How is this done in python?
> >
> > I mean the only thing that I know that works for sure is
> > Edit file2.py
> > 1. Bail out of ipython
> > 2. Manually delete file2.pyc
> > 3. Launch ipython
> > 4. Run main.py
> >
> > Naturally, this is a relatively slow and annoying process...
> > Is there a better way?
> 
> You should not have to delete the .pyc file. The interpreter should
> see that the .py file is more recent and re-compile automatically.
> What is the relationship between main.py and file2.py? Probably you
> need to reload file2. I think the problem is that the loaded module
> has been cached, not that it is not being re-compiled. Re-launching
> ipython clears the module cache. What happens if you try the above
> sequence without deleting file2.pyc?
> 
> Kent

main.py imports file2  like

/pseudo snippet of main.py
import file2 as f2

...
g = f2.someroutine(...)

/end pseudo snippet

It is probably the module cache then.  How is the module cache updated?
Can it be updated "automatically"?

Bruce

******************************
Neither the footer nor anything else in this E-mail is intended to or constitutes an <br>electronic signature and/or legally binding agreement in the absence of an <br>express statement or Autoliv policy and/or procedure to the contrary.<br>This E-mail and any attachments hereto are Autoliv property and may contain legally <br>privileged, confidential and/or proprietary information.<br>The recipient of this E-mail is prohibited from distributing, copying, forwarding or in any way <br>disseminating any material contained within this E-mail without prior written <br>permission from the author. If you receive this E-mail in error, please <br>immediately notify the author and delete this E-mail.  Autoliv disclaims all <br>responsibility and liability for the consequences of any person who fails to <br>abide by the terms herein. <br>
******************************


More information about the Python-talk mailing list