[Python-Dev] Draft PEP: "Simplified Package Layout and Partitioning"

Antoine Pitrou solipsis at pitrou.net
Fri Jul 22 02:38:05 CEST 2011


On Thu, 21 Jul 2011 17:31:04 -0700
Glenn Linderman <v+python at g.nevcal.com> wrote:
> 
> If I have (on sys.path), a directory "x" containing a "y.py" module, and 
> later (on sys.path), another directory "x" containing a "y.py" module, 
> what is "from x import y" supposed to do?
> 
> OR
> 
> If I have (on sys.path), a module "x.py" containing, say:
> 
>     y = 5
> 
> and later (on sys.path), another module "x.py" containing, say:
> 
>     y = 6
> 
> what is "from x import y" supposed to do?
> 
> 
> I guess I don't see how this new proposal makes anything more confusing 
> than it already is?

It does. In your two examples, the "x.py" files (or the "x" directories)
live in two different base directories; imports are then resolved in
sys.path order, which is expected and intuitive.

However, you can have a "x.py" file and a "x" directory *in the same
base directory which is present in sys.path*, meaning sys.path can't
help disambiguate in this case.

Regards

Antoine.




More information about the Python-Dev mailing list