as explained earlierpart of the purpose of __init___ py files in regular packages is to declare the directory as package--it tells python to use the directoryrather than skipping ahead to possible file of the same name later on the path this avoids inadvertently choosing noncode subdirectory that accidentally appears early on the pathover desired module of the same name because namespace packages do not require these special filesthey would seem to invalidate this safeguard this isn' the casethough--because the namespace algorithm outlined earlier continues scanning the path after namespace directory has been foundfiles later on the path still have priority over earlier directories with no __init__ py for exampleconsider the following directories and modulesc:\codemkdir ns :\codemkdir ns :\codemkdir ns \dir :\codenotepad ns \dir\ns py :\codetype ns \dir\ns py print( 'ns \dir\ns py!'the ns directory here cannot be imported in python and earlier--it' not regular packageas it lacks an __init__ py initialization file this directory can be imported under though--it' namespace package directory in the current working directorywhich is always the first item on the sys path module search path irrespective of pythonpath settingsc:\codeset pythonpathc:\codepy - import ns importerrorno module named ns :\codepy - import ns ns ns __path__ _namespacepath([\\ns '] single-directory namespace package in cwd but watch what happens when the directory containing file of the same name as namespace directory is added later on the search pathvia pythonpath settings--the file is used insteadbecause python keeps searching later path entries after namespace package directory is found it stops searching only when module or regular package is locatedor the path has been completely scanned namespace packages are returned only if nothing else was found along the wayc:\codeset pythonpath= :\code\ns \dir :\codepy - import ns use later module filenot same-named directoryns \dir\ns pyns module packages