[Python-Dev] Write All New Import Hooks (PEP 302) in Python, Not C

Lalo Martins lalo@laranja.org
Fri, 27 Dec 2002 21:03:41 -0200


On Fri, Dec 27, 2002 at 11:59:48PM +0100, Just van Rossum wrote:
> 
> The sys.meta_path feature adds 32 lines to import.c, it's *really*
> useful and easy to use. I would be *extremely* sad to see it go.
> 
> (I had an immediate use for it in test_importhooks.py: after a test is
> run I wanted to unload the modules that were imported during the test.
> The ImportTracker is a meta importer and only *records* imports. It's
> seven lines long and helped me clean up the test script quite a bit. Not
> a typical use case perhaps, but to me still demonstrates the power of
> meta_path quite well. Doing the same with __import__ is of course
> possible, but is much more cumbersome and doesn't have the same
> semantics.)

Just my 1.5c - PyUnit has a similar use case.  It is documented (well) at
http://pyunit.sourceforge.net/notes/reloading.html

[]s,
                                               |alo
                                               +----
--
            Those who trade freedom for security
               lose both and deserve neither.
--
http://www.laranja.org/                mailto:lalo@laranja.org
         pgp key: http://www.laranja.org/pessoal/pgp

Eu jogo RPG! (I play RPG)         http://www.eujogorpg.com.br/
GNU: never give up freedom                 http://www.gnu.org/