I don't agree with this:
- Imports should usually be on separate lines, e.g.:
Yes: import os
import sys
No: import sys, os
I always write simple imports together. I don't see any advantage to writing them all on separate lines: all it does is add bloat to the top of each source file, and turn something concise and easy to type into something that's borderline boilerplate, eg. something that's so verbose it starts to be tempting to copy and paste from other files.
This is instantly readable and understandable:
import sys, os, time, gc, inspect, math, doctest
It's short, easy to skim, and easy to add to. I do use multiple import
statements if there are too many on one line, of course, or if I need a from
import.
I also do generally keep standard library imports separate from imports of my own modules and other libraries, which agrees with the concept of grouping PEP8 recommends.