how to unimport something

Fredrik Lundh fredrik at pythonware.com
Sun Feb 18 06:34:42 EST 2001


Sean 'Shaleh' Perry wrote:
> application does this:
>
> init
> do step A (takes some time)
> do step B (takes even longer)
> do step C (not that long)
>
> each step is decently independent of the previous.  I plan to have A, B and C
> implemented as separate modules (perhaps several for each step) and load each
> as I need them.

not sure what this has to do with "unimporting", so I'm
probably missing something here, but is there any reason
you cannot do this in the obvious way:

import init_module
init_module.run()

if need_step_A:
    import step_A
    step_A.run()

if need_step_B:
    import step_B
    step_B.run()

if need_step_C:
    import step_C
    step_C.run()

Cheers /F

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list