This is my Python module:
main.py
fib/
__init__.py
fib.py
hello.py
fib.py defined function fib(), hello.py define function hello().
main.py is
from fib import *
hello()
__init__.py is
__all__ = ["fib", "hello"]
I write this code just for practice.Not for work
I run main.py it print:
Traceback (most recent call last):
File "tes.py", line 5, in <module>
hello()
TypeError: 'module' object is not callable
Why? I had list hello in __all__
You’ve imported the
hellomodule with thefrom fib import *line, but you are not referencing thehellofunction in that module.Do this instead:
or this: