as the title says, I am confused about sub-subpackages. My package structure is the following:
draw \
__init__.py
base \
__init__.py
utils.py
events.py
master.py
basegui.py
Now, the first line of draw.base.events is the following:
import draw.base.utils as _utils
And the first line of draw.base is:
from draw.base.events import Event, RenderEvent, InputEvent, MouseEvent, KeyboardEvent
Just checking the code for SyntaxErrors with IDLE:
import draw.base as base
gives the following AttributeError:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import draw.base
File "Z:\Eigene Dateien\Eigene Dokumente\Python\draw\base\__init__.py", line 4, in <module>
import draw.base.events as events
File "Z:\Eigene Dateien\Eigene Dokumente\Python\draw\base\events.py", line 10, in <module>
import draw.base.utils as _utils
AttributeError: 'module' object has no attribute 'base'
Can someone explain to me whats the issue ?
In order to import
draw.base.utilsindraw.base.eventsPython needs to importdraw.basewhich is being imported now so there is nodraw.baseyet. You can replaceimport draw.base.utilswithimport utils(you can also use something likefrom ..base import utilsin 2.7, 3.x or withfrom __future__ import absolute_import) indraw.base.eventsto break the circle.