I do not like to blindly follow without a good reason. Like PEP20: Zen of Python states that Reading Counts
PEP8 "separate line for import" works for a general perspective. Although I respect him (i.e. Guido's Opinion), I will not always strictly follow these conventions all the time.
An exception to this rule is only when the # code is less than the # import module. for example 2 lines of code, but 4 module imports.
This is more readable: (in my opinion)
import os, sys, math, time def add_special(): return time.time() + math.floor(math.pow(sys.api_version + os.getpid(), 2))
instead of this
import os import sys import math import time def add_special(): return time.time() + math.floor(math.pow(sys.api_version + os.getpid(), 2))
But this issue of readability is different for every person.
source share