3 ms·
https://www.python.org/dev/peps/pep-0420/ https://www.python.org/dev/peps/pep-0420/ Python 3.3+ no longer requires the `__init__.py` file to make a package. >
by terom 5y ago
https://www.python.org/dev/peps/pep-0420/ https://www.python.org/dev/peps/pep-0420/ Python 3.3+ no longer requires the `__init__.py` file to make a package.
> You would then `import .foo`
The `import .foo` is a syntax error, and `from . import foo` does not work for scripts [1].
The basic `import foo` works if the directory is on your PYTHONPATH. That will be the case if you run `bar.py` as a script.
It gets more difficult if you want to separate scripts and importable modules into separate sibling directories (bin vs lib). You can't use relative imports to get around that, you need to use a virtualenv (or manual PYTHONPATH wrangling).
[1] https://stackoverflow.com/a/14132912 https://stackoverflow.com/a/14132912