[Python-Dev] New universal import mechanism ( Re: [Python-checkins] python/dist/src/Python import.c,2.210,2.211)

Guido van Rossum guido@python.org
Tue, 03 Dec 2002 03:59:05 -0500


> My users want extension modules to be able to control how their
> attributes are imported when using "import *". In particular,
> Boost.Python includes a kind of multimethod facility, and some of my
> users would like it if
> 
>       from bpl_extension import *
> 
> caused multimethod definitions in bpl_extension to be /merged/ into
> the current module, rather than replacing any multimethod bindings
> with the same name in the current module.

Alas, the current import hooking mechanisms don't allow control over
this (the interpretation of * is hardcoded).  Feel free to suggest an
API and/or implementation of a hook for that, after reading how it's
done now.  The crucial code is import_all_from() in ceval.c.

--Guido van Rossum (home page: http://www.python.org/~guido/)