[Python-Dev] Relative vs. absolute imports (original) (raw)

M.-A. Lemburg mal at egenix.com
Mon May 17 18:36:29 EDT 2004


Phillip J. Eby wrote:

At 05:37 PM 5/17/04 +0200, M.-A. Lemburg wrote:

Samuele Pedroni wrote:

At 16:55 17.05.2004 +0200, M.-A. Lemburg wrote:

Are you saying that you are not going to change the default import() implementation, only the way it is called ? (I wonder how you'll enforce the 'absolute only' strategy then) if you pass globals = {} you get absolute imports from import, Ahh, a hidden feature :-) I didn't know that one yet. More of an emergent property. Keep in mind that the current relative mechanism is always relative to something, and that "something" is defined by the globals['name'], if any. If there is no 'name', then the import has to be absolute.

Right. Point taken on that account. Perhaps a note should go into the PEP that the internal mechanism is not going to change and that instead only the syntax will get enhanced.

I still don't believe that we need to break code in order to introduce relative imports, though, certainly not before Py3k.

I also think that prepending "from ." to all package local imports in order to overcome this looks like silly (the dot is hardly visible in an editor), but that may be just me.

BTW, what are you going to do about "from . import *" and "from .. import *" ?

-- Marc-Andre Lemburg eGenix.com

Professional Python Services directly from the Source (#1, May 18 2004)

Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/


EuroPython 2004, Göteborg, Sweden 19 days left

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::



More information about the Python-Dev mailing list