Hi everybody,
while I'm still thinking about writing the import manager, here
is a patch that implements the walk-up-the-hierarchy import scheme
that got so much positive feedback. I'm intending to use this
implementation as proof of concept for the switch to my new
package structure, but wouldn't mind seeing something like it
the distribution as well ;-)
It changes the default import mechanism to work like this:
>>> import d
try a.b.c.d
try a.b.d
try a.d
try d
fail
instead of just doing the current two-level lookup:
>>> import d
try a.b.c.d
try d
fail
As a result, relative imports referring to higher level packages
work out of the box without any ugly underscores in the import name.
Plus the whole scheme is pretty simple to explain and straightforward.
Since the patch is so small, I attached it to this mail. Hope
you don't mind. The ZIP archive also contains a sample package
which demonstrates the feature. Run Python with -v flag to see how
the new scheme works.
Feedback is most welcome. I am especially interested whether the
scheme breaks any existing packages.
--
Marc-Andre Lemburg
______________________________________________________________________
Y2000: 81 days left
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/
while I'm still thinking about writing the import manager, here
is a patch that implements the walk-up-the-hierarchy import scheme
that got so much positive feedback. I'm intending to use this
implementation as proof of concept for the switch to my new
package structure, but wouldn't mind seeing something like it
the distribution as well ;-)
It changes the default import mechanism to work like this:
>>> import d
try a.b.c.d
try a.b.d
try a.d
try d
fail
instead of just doing the current two-level lookup:
>>> import d
try a.b.c.d
try d
fail
As a result, relative imports referring to higher level packages
work out of the box without any ugly underscores in the import name.
Plus the whole scheme is pretty simple to explain and straightforward.
Since the patch is so small, I attached it to this mail. Hope
you don't mind. The ZIP archive also contains a sample package
which demonstrates the feature. Run Python with -v flag to see how
the new scheme works.
Feedback is most welcome. I am especially interested whether the
scheme breaks any existing packages.
--
Marc-Andre Lemburg
______________________________________________________________________
Y2000: 81 days left
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/