Did a little experiment by doing somelib.pyand somelib/__init__.py
then tried the following
>>> from somelib import foo
in somelib/__init__.py
>>>
Obviously python prefers directory-based file-based module
As @scnerd points out, this may be random behavior, but this is what I see in the default implementation.
If you want to know how this happens, you should probably look through importlib for horrible details.
source
share