[Import-sig] Re: Proposal for a modified import mechanism.
Sat, 10 Nov 2001 10:13:47 -0800
> I'd like to ask the Python developers if they'd consider
> (a) changing the way the current import works to do what I
> proposed, or,
> (b) add a new keyword like 'rimport' (or something) that does this
> recursive search through parent packages and loads modules. This
> was actually suggested by Gordon McMillan. Gordon actually
> suggested something stronger -- import only supports absolute
> names, rimport is relative import and rrimport is a recursive
> relative import. But this would break the current import since
> import currently aupports some relative lookup. So maybe import
> and rimport is a workable solution?
I'd rather introduce a __parent__ module attribute (in addition to the
existing __name__) so that, for instance, the following would do your job:
from __parent__.__parent__.toto import something
In its spirit, this is similar to the '..' of the file systems.
For top-level modules, __parent__ would be None.
I'm personnally against anything that enlarges the search path uselessly;
because the obvious reason of increased name space collision, increased
run-time overhead etc...