[Python-Dev] Re: PEP 328 - Relative Imports (original) (raw)

M.-A. Lemburg mal at egenix.com
Fri Sep 10 19:05:32 CEST 2004


Barry Warsaw wrote:

On Fri, 2004-09-10 at 07:46, Jim Fulton wrote:

I find explicit relative imports easier to read, as it reduces the noise level. I like the fact that local imports look different from non-local ones. Yes, +1. The most important thing IMO is that there be an explicit way to spell whatever the default isn't. I was just grumbling the other day because I had to rename a submodule foologging.py instead of the more natural logging.py because that module suddenly wanted to start importing the global logging package.

If that's the only reason, then placing the whole Python standard lib under a new top-level package name would be the better solution, starting with P3k.

I wasn't suggesting not to have relative imports. It is just that most third-party packages nowadays rely on the current import lookup mechanism (first local, then global). All of these would break the day absolute imports become the default.

Whether or not relative imports look right is probably more a question of taste than anything else... I find getting the number of dots right just as hard as getting the number '../' right in an relative path name.

But back to the original question: should absolute imports be made a P3k feature or will we have a sys.setimportscheme() hook to tune the setting on a per application basis ?

-- Marc-Andre Lemburg eGenix.com

Professional Python Services directly from the Source (#1, Sep 10 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/


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



More information about the Python-Dev mailing list