[NCLUG] Reloading Python Module?

Evelyn Mitchell efm at tummy.com
Tue Aug 6 14:14:38 MDT 2002


* On 2002-08-06 20:04 marciot <marciot at holly.colostate.edu> wrote:
> Hi,
> 
> 
> However, often I edit "foo.py" to add new functions as the
> need arises. I would like to have python reload the module.
> Apparently doing the "import" again does not reload it and
> I end up having to quit python and restart it before the new
> functions appear.
> 
> Is there an easier way? It would be awesome if I could have
> python autodetect the modifications and reload the file for
> me, but I'ld be satisfied if at least I could do it manually.

You can use the built-in function reload() for this, but there are some
gotchas:
   http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-50

Again, you may want to consider signing up for the frpythoneers mailing
list to ask these sorts of questions. There are many more python
programmers on that list than this one:
   http://lists.community.tummy.com/mailman/listinfo/frpythoneers
(I think I got the url correct this time.)

-- 
Regards,                    tummy.com, ltd 
Evelyn Mitchell             Linux Consulting since 1995
efm at tummy.com               Senior System and Network Administrators
                            http://www.tummy.com/



More information about the NCLUG mailing list