This is my file structure:
annotations
Helper.py
annotations.py
test
HelloWorld.py
This is HelloWorld.py, a simple HelloWorld class:
from annotations.annotations import annie
class HelloWorld:
@annie.mydecorate
def something():
echo 'Hello World'
And within annotations.py, I’m just declaring some simple decorators:
from annotations.Helper import Helper
class annie:
@staticmethod
def mydecorate(func):
Helper.prepare()
print func.__name__
Here I get an error saying No such module: Helper. I guess this is happening when the module HelloWorld is being loaded, it is loading the annotations module, but the function is being called during the module being loaded at which time the Helper module is not loaded. I’m not sure how correct I am, but I am just looking for a solution here.
Is the problem something else? Can I import modules like I am doing in a file which declares decorators? Any help would be greatly appreciated.
Regards,
rohan
In
annotations.py, try:or (relative imports, Python 2.5 and up)