While I was building a Python package and I came across the necessity of calling the whole package ( import tools
) but I could not find the package's modules. This was the result when I called dir(tools)
:
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
In other hand when I tried to import modules directly ( from tools import A, B
) it worked.
What can be causing it?
This is the simplified package structure:
tools/
setup.py
tools/
__init__.py
A.py
B.py
Package was generated using cookiecutter's audreyr/cookiecutter-pypackage template
import Tools
will expect Tools to be a class name in the Tools module
you can try
from tools import *
to import every class in that module
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.