[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Import module from a different subdirectory

2019?5?17?(?) 9:25 Rich Shepard <rshepard at appl-ecosys.com>:
> My understanding is that Python3 does not require subdirectories to have an
> __init__.py file, only Python2 does. If that's not correct I'll add the
> blank file.

This is slightly off topic (not relating to your problem), but please don't
think "Python 3 doesn't require __init__.py for packages".
It is common misunderstanding.

Package directory without __init__.py is "namespace package".
Namespace package is not a regular package.  See [1] for detail.

[1]: https://packaging.python.org/guides/packaging-namespace-packages/

There are some difference between regular package and namespace package.
They have different module search order.  Testing tools including unittest
doesn't search namespace package.  (If they do, they may take minutes
to search million files in `node_modules` directory in your project!)
So abusing namespace package will bite you at some point.

Inada Naoki  <songofacandy at gmail.com>