From 9ca37200735c6728467b1cc053f69fccbc4b9ee4 Mon Sep 17 00:00:00 2001 From: "Eric V. Smith" Date: Wed, 2 May 2012 11:16:48 -0400 Subject: [PATCH] Clarify path scanning logic. --- pep-0420.txt | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/pep-0420.txt b/pep-0420.txt index 3dba5fde8..682aea35b 100644 --- a/pep-0420.txt +++ b/pep-0420.txt @@ -114,19 +114,30 @@ namespace package creation. There will be no marker file or directory for specifing a namespace package. During import processing, the import machinery will continue to -iterate over the parent path as it does in Python 3.2. While looking -for a module or package named "foo": +iterate over each directory in the parent path as it does in Python +3.2. While looking for a module or package named "foo", for each +directory in the parent path: - * If ``foo/__init__.py`` is found, a regular package is imported. - * If not, but ``foo.{py,pyc,so,pyd}`` is found, a module is imported. - * If not, but ``foo`` is found and is a directory, it is recorded. + * If ``/foo/__init__.py`` is found, a regular package is + imported and returned. -If the scan along the parent path completes without finding a module -or package and at least one directory was recorded, then a namespace -package is created. The new namespace package: + * If not, but ``/foo.{py,pyc,so,pyd}`` is found, a module + is imported and returned. + + * If not, but ``/foo`` is found and is a directory, it is + recorded and the scan continues with the next directory in the + parent path. + + * Otherwise the scan continues with the next directory in the parent + path. + +If the scan completes without returning a module or package, and at +least one directory was recorded, then a namespace package is created. +The new namespace package: * Has a ``__file__`` attribute set to the first directory that was found during the scan, including the trailing path separator. + * Has a ``__path__`` attribute set to the list of directories there were found and recorded during the scan.