Alphabetizing `import` Statements I did a quick google search, and it didn't show up.

I haven't noticed it posted in pylint.py, or PEP8.py.

My emacs mode doesn't warn me if my imports are listed arbitrarily...does anyone do this?

import longest.modulename.first
import medium.sizename
import short
import sys
import os

from imports import go_at_the_bottom
from length import does_matter
from still import cascading


This is typically how I do it. But after a while, the list gets big!

I think this might work better, but it's kind of ugly:

import longest.modulename.first
import medium.sizename
import os
import short
import sys

from BeautifulSoup import BeautifulSoup as BS
from BeautifulSoup import BeautifulStoneSoup as BSS #froms are sorted by import
from imports import go_at_the_bottom
from length import does_matter
from mechanize import Browser as br
from still import cascading


What's the standard for this? I like the look of the cascading imports, but I also like the utility of searching for what's being used in the script quickly.

Is there another approach to this that I didn't cover that you use?
PEP-8 says:


  Imports should be grouped in the following order:
  
  
  standard library imports
  related third party imports
  local application/library specific imports
  
  
  You should put a blank line
  between each group of imports.


I follow it and then sort modules alphabetically within each group without separating from from the other imports, like this:

import re
import os
from   pprint import pprint
import traceback

import lxml

from   readers    import SomeReader
from   util.stuff import (stuff_init, stuff_close, StdStuff,
                          OtherStuff, BlahBlah)