"M.-A. Lemburg" wrote:
James C. Ahlstrom wrote:
First, I am not all that opposed to having a notion of ".." available in the import statement. If we can write zope.dir1.mod1 which is a relative import going down, maybe we can write ../dir2/mod2 or something spelled differently. But I think there would still be problems.
We would be relying on all package authors to use ".." or "__" within their package. But it is more natural to write zope.this.that or mx.this.that everywhere, and that is what people have in fact done. Probably there would be bugs and at least annoyance.
Think of it as an opportunity: it makes intra-package imports very simple without hard-wiring paths to submodules into the package.
In the end, having written a self-contained package is a "feature" of that package. Other authors can then say: ok, I can plugin your package if it's self-contained.
Well said. It really should be possible to provide *self-contained* package hierarchies.
I have a feeling that this discussion is loosing its grip on reality a bit. Jim and I are not argueing to change Python's face, internal structure or look&feel. The '__' thing doesn't harm anyone, doesn't break any functionality or code. It is even now already possible using import hooks and has been implemented before in ni.py using just that technology.
All that we are talking about is reviving relative imports so that its usage is possible *without* adding yet another hook. This is not about the pros and cons of deeply nested packages and neither about advantages of shallow structures. Its only about adding semantics to the string '__' used in import statements. Nothing more. People are not forced to use it. Besides, if used it will be a package internal technique and not be visible to users of that package.
Now why would anyone want to make life harder for package authors ?
I don't think nearly enough Python code has been packagized. Packages are critcal for large projects and for reuse of code within large projects. There are at least two people in this discussion that are trying hard to make use of packages and have observed a significant problem. If we really want to encourage developers of reusable Python software to use packages, then I think it would be wise to pay attention to people who are actively using packages and have encountered problems. Jim -- Jim Fulton mailto:jim@digicool.com Technical Director (888) 344-4332 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.