PSA: Namespaces
I’m not sure where I first heard this—it may have been Raymond Hettinger's talk at PyCon US 2012—but it’s important to remember that the function of namespaces is not to create taxonomies, it is to avoid naming collisions.
Once you grok this, you realize why we don't do this in Python:
from org.pocoo.flask.templates.signals import template_rendered
Instead we do this:
from flask import template_rendered
But there are still libraries out there that promote some nasty imports.
from django.conf.urls.defaults import url, patterns, include
Wouldn't this be better?:
from django.urls import url, patterns, include
</PSA>
Written by Zachary Voase
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#