python guidelines on import statements?

asked 2015-06-24 16:11:14 -0500

Hi,

I was going through the horizon tutorial on adding a new panel. The instructions result in an auto-generated urls.py that looks like this:

from django.conf.urls import patterns
from django.conf.urls import url

from openstack_dashboard.dashboards.mydashboard.mypanel.views import IndexView

urlpatterns = patterns(
    '',
    url(r'^$', IndexView.as_view(), name='index'),
)

The tutorial goes on to say:

Adjust the import of IndexView to make the code readable:

from openstack_dashboard.dashboards.mydashboard.mypanel import views

Replace the existing url pattern with the following line:

url(r'^$', views.IndexView.as_view(), name='index'),

Is there a community coding standard/guideline that prefers importing a package over importing a class or is this more of an opinion on readability? I personally find the originally generated code perfectly readable...

Thanks, John

edit retag flag offensive close merge delete