#23860: Document the preferred imports order
-------------------------------+--------------------
Reporter: wrwrwr | Owner: nobody
Type: New feature | Status: new
Component: Documentation | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
I think it would be nice to have the (soft?) convention on imports order
documented. It's said that Django has one, but I've recently spent some
time trying to figure out what it is and couldn't find any precise info or
get a consistent view based on the source.
[https://www.python.org/dev/peps/pep-0008#imports PEP 8] only asks to put
imports on separate lines at the top of the file, guides to make "standard
library", "related" and "local" groups, recommends absolute imports
(unless dealing with complex package layouts), and discourages the use of
"*" in most cases.
A short example on the
[https://docs.djangoproject.com/en/dev/internals/contributing/writing-code
/coding-style/ coding style] page would be enough. Things to mention:
* alphabetical order for modules, classes and objects (within groups);
* modules before classes, other objects after classes?
* "import" before "from ... import"?
* line breaking of lengthy imports.
Some conventions from other projects: [http://google-
styleguide.googlecode.com/svn/trunk/pyguide.html#Imports_formatting
Google], [https://github.com/reddit/reddit/wiki/PythonImportGuidelines
reddit], [http://docs.openstack.org/developer/hacking/#real-world-import-
order-examples OpenStack],
[http://docs.plone.org/external/plone.api/docs/contribute/conventions.html
#about-imports Plone].
--
Ticket URL: <https://code.djangoproject.com/ticket/23860>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.fa1c9a015edd020454f4a0ecff85ebff%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.