issue on internal import in a package

Frank Millman frank at chagford.com
Sun Feb 27 14:38:10 CET 2011


"人言落日是天涯,望极天涯不见家" <kelvin.you at gmail.com> wrote in message 
news:fa94323b-d859-4599-b236-c78a22b3d4dd at t19g2000prd.googlegroups.com...
> On Feb 27, 9:22 pm, "Frank Millman" <fr... at chagford.com> wrote:
>
> This behavior is by design or just a bug for Python3.x ?

Definitely by design.

Have a look at PEP 328 - http://www.python.org/dev/peps/pep-0328/

"In Python 2.4 and earlier, if you're reading a module located inside a 
package, it is not clear whether
import foo
refers to a top-level module or to another module inside the package. As 
Python's library expands, more and more existing package internal modules 
suddenly shadow standard library modules by accident. It's a particularly 
difficult problem inside packages because there's no way to specify which 
module is meant. To resolve the ambiguity, it is proposed that foo will 
always be a module or package reachable from sys.path. This is called an 
absolute import."

HTH

Frank





More information about the Python-list mailing list