I have a few packages that include modules named util
, so that it becomes difficult to tell which util
module is referred to if you see something like this:
util.some_func()
What I would like to do is something like this:
views.util.some_func()
...but I can't figure out a good way to import this. Of course this doesn't work:
from apture.main import views.util
The best I can come up with is to add from . import views
in views/__init__.py
, and then do this:
from apture.main import views
views.util.some_func()
Is there 开发者_Python百科any better way to do this? The only other alternative I can think of is:
import apture.main.views.util
from apture.main import views
views.util.some_func()
...but that's a bit ugly.
Would this work for you:
from apture.main.view import util as view_util
精彩评论