[Python-Dev] Relative import (original) (raw)

Greg Ewing greg at cosc.canterbury.ac.nz
Wed Dec 17 20:57:24 EST 2003


Jack Jansen <Jack.Jansen at cwi.nl>:

If you have a complex package with, say, three levels you may want to scan up through the levels of your own package. However, if your package is later incorporated in a third party package I can hardly imagine that you want to scan in there too.

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.

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.

Referring to related modules in your package is a different matter -- for that, you should probably be using explicitly relative references.

Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+



More information about the Python-Dev mailing list