[Python-ideas] Module local namespaces

Josiah Carlson jcarlson at uci.edu
Thu Jan 4 02:51:28 CET 2007


"Guido van Rossum" <guido at python.org> wrote:
> On 1/3/07, Josiah Carlson <jcarlson at uci.edu> wrote:
> > -1 .  The only thing that possibly should be fixed is that modules
> > should only be inserted into sys.modules after they have been imported
> > completely and correctly.
> 
> I agree, but there's the wrinkle that during recursive imports you
> want partially-imported modules to be importable. I believe we once
> agreed on a solution but I don't recall what it was. Does anybody
> remember?

I don't remember what was agreed upon, but what about something like...

    try:
        newmodule = ...
        sys.modules[name] = newmodule
        handle_the_import(newmodule, ...)
    except:
        del sys.modules[name]
        raise

 - Josiah




More information about the Python-ideas mailing list