I have the following file structure in a package:
test/
test/__init__.py
test/testmodule.py
caller.py
On testmodule.py:
def myfunc():
print('wew')
On __init__.py:
from . import testmodule
from .testmodule import *
__all__ = ['testmodule']
And on caller.py:
from test import *
if __name__ == '__main__':
myfunc()
But I get a "NameError: 'myfunc' is not defined". If I do instead test.myfunc()
, it works. How can I do from <module> import *
so that it works without needing to add the module name to the call?