Was this import behaviour planned...?

Gordon McMillan gmcm at hypernet.com
Thu Jun 21 05:01:22 CEST 2001


Pierre Fortin wrote: 

>The core question:  if "import foo.bar.baz" really means
>"foo/bar/baz...", shouldn't import ignore any files such as ./foo.py,
>foo/bar.py, etc....?

But it doesn't. It means "find something in foo named bar, then find 
something in that named baz". foo/bar/baz.py is just one implementation, 
and it requires foo/__init__.py and foo/bar/__init__.py. But foo.bar could 
be a module, and baz an object in foo.bar, or even worse.

Or maybe they're modules, but not in your filesystem.

Planned? No way. Packages were introduced after someone hacked them up with 
a module name "ni" and lots of people started using it 'cause one flat 
namespace was just too restrictive.

- Gordon



More information about the Python-list mailing list