[Python-Dev] Relative import
Guido van Rossum
guido at python.org
Wed Dec 17 21:02:33 EST 2003
> The main use I have in mind for scan-upwards is for when you're
> importing something that's *not* part of your package. It's probably
> top-level, but someone might want to put you and it into a package one
> day, so you shouldn't hard-wire a top-level reference to it.
You could hardwire a relative reference to it though.
> That's why I think scan-upwards should be the default -- because you
> never know when someone might want to repackage you into a different
> environment in the future.
I don't know if I want to encourage this kind of repackaging. There
are various downsides (such as possible deployment of two differently
repackaged versions of the same code) and I think some of the burden
should be placed on the repackager. After all, after repackaging, the
repackager is really responsible for the repackaged code.
The nice thing about absolute imports is that it's very simple to
write a tool that changes all absolute imports of a given package into
some other import, if you really want that.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list