[Import-SIG] [Python-ideas] My objections to implicit package directories
Guido van Rossum
guido at python.org
Tue Mar 13 22:23:12 CET 2012
On Tue, Mar 13, 2012 at 1:25 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> Here's one idea to address the PEP 395 concern.
>
> Traverse up the directory tree until you hit one of the following three markers:
>
> * there is no __init__.py in the current directory (in the case where
> there was one adjacent to the original module)
> * current directory is on sys.path
> * setup.py is in the current directory
>
> All these indicate that you have left the package. If you make it to
> the FS root, the module would not be considered to exist in a package.
>
> The third option is the new idea. As a bonus, using setup.py as a
> marker would also nudge people toward packaging.
I like it!
FWIW, Thomas Wouters disagrees with the goal of PEP 395 -- he would
much rather issue an error message when you're trying to execute a
file living inside a package (without using -m) instead of Nick's
proposal to fix the situation. But that's a second-order issue; Eric's
algorithm (or some variant of it) might work for either approach.
Anyway, I'd like to stay out of *that* particular discussion -- either
way it doesn't affect my position on namespace packages.
--
--Guido van Rossum (python.org/~guido)
More information about the Import-SIG
mailing list