[Python-talk] Modules force recompilation?
Kent Johnson
kent37 at tds.net
Thu Feb 4 20:29:17 EST 2010
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
More information about the Python-talk
mailing list