python - Importing modules in a file that declares decorators -
this file structure:
annotations helper.py annotations.py test helloworld.py this helloworld.py, simple helloworld class:
from annotations.annotations import annie class helloworld: @annie.mydecorate def something(): echo 'hello world' and within annotations.py, i'm declaring simple decorators:
from annotations.helper import helper class annie: @staticmethod def mydecorate(func): helper.prepare() print func.__name__ here error saying no such module: helper. guess happening when module helloworld being loaded, loading annotations module, function being called during module being loaded @ time helper module not loaded. i'm not sure how correct am, looking solution here.
is problem else? can import modules doing in file declares decorators? appreciated.
regards, rohan
in annotations.py, try:
import helper or (relative imports, python 2.5 , up)
from . import helper
Comments
Post a Comment