Most "professional" python modules can be imported like so:
from pythonfile import class
And that is how I usually import my own classes that are in my local file system/current directory.
But after looking at several posts and python.org documents, I still can't get my python module (on Pypi.org) to import like that.
The only way I can get my module to import is like so:
from example.example import Example
(Example is a class within example.py)
How to I get my module to import like so:
from example import Example
My module on Pypi has a folder structure is like this and installs fine via pip:
example/
|
├── example/
│ ├── example.py
│ ├── __init__.py
│ └── __pycache__
│ └── __init__.cpython-36.pyc
|
|
├── __init__.py
├── LICENSE
|
├── README.md
└── setup.py
Should I add import statements to one of the __init__.py
files?
I want developers to be able to install the package via pip, and then use a simple
from example import Example
and not from example.example import Example
Thank you.
when you have a look at some other big packages they usually have in their top __init__.py something like
from .modulex import *
from .moduley import *
the dot means, python is looking in current package before rest of the PYTHONPATH.