[Python-Dev] Relative package imports
mal at lemburg.com
Mon Jun 21 16:36:58 CEST 1999
Mark Hammond wrote:
> > It seems that there is not much interest in the topic...
> > I'll be offline for the next two weeks -- maybe someone could
> > pick the thread up and toss it around a bit while I'm away.
> OK - here are my 2c on it:
> Unless I am mistaken, this problem could be solved with 2 steps:
> * Code moves to Python packages.
> * The standard Python library move to a package.
> If all non-trivial Python program used packages, and some agreement on a
> standard namespace could be met, I think it would be addressed. There was
> a thread on the newsgroup about the potential naming of the standard
> You did state as much in your proposal - indeed, you state "to ease the
> transition". Personally, I dont think it is worth it, mainly because we
> end up with a half-baked scheme purely for the transition, but one that can
> never be removed.
With "easing the transition" I ment introducing a way to do relative
package imports: you don't need relative imports if you can be
sure that the package name will never change (with a fixed naming
scheme, a la com.domain.product.package...). The smarter import
mechanism is needed to work-around the pickle problems you face
(because pickle uses absolute package names).
> To me, the question is one of:
> * Why arent Zope/PIL capable of being used as packages.
> * If they are (as I understand to be the case) why do people choose not to
> use them as such, or why do the authors not recommend this?
> * Is there a deficiency in the package scheme that makes it hard to use?
> Eg, should "__" that ni used for the parent package be reinstated?
I guess this would help a great deal; although I'd personally
wouldn't like yet another underscore in the language. Simply leave
the name empty as in '.submodule' or '..subpackage.submodule'.
Y2000: 193 days left
Python Pages: http://www.lemburg.com/python/
More information about the Python-Dev