I've got a package called elements that contains some stuff like button, trifader, poster. In the Button class, I am doing from elements import *
This executes OK, and when I try to print(poster), also works OK and functions as expected. However, when I do print(trifader), NameError: name 'trifader' is not defined. Even though trifader and poster are in the same package, poster is defined, but trifader isn't? How weird. Is there any explanation for this?
The directory structure of the elements package is this:
Elements:
__init__.py
trifader.py
button.py
poster.py
Also, some other stuff that isn't really relevant.
Each .py file contains a class with the name of the .py, for example, trifader.py has a class called TriFader.
If your __init__.py doesn't have __all__ defined (thus restricting what is imported using from X import *), then you probably have a circular import somewhere which is causing a module to be referenced before its' definitions have been evaluated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With