Using the structure from the Python docs:
sound/
__init__.py
effects/
__init__.py
echo.py
surround.py
reverse.py
Say I want to import sound.effects
and get a list of available effects. I could do this by declaring a module-level variable in sound.effects
and then appending to it when each .py file is imported. So sound/effects/_init_.py might look like this:
effectList = []
import echo
import surround # Could write code to import *.py instead
...
From my main code I can now access sound.effects.effectList
to get a list of effects, but how do I access effectList
from within echo.py to do the actual append? I'm stuck trying to get access to the variable:
# None of these work :-(
# from . import self
# from .. import effects
# import sound.effects
sound.effect.effectList.append({'name': 'echo'})