问题
The PEP8 style guide section on imports seems to be a bit ambiguous.
From: https://www.python.org/dev/peps/pep-0008/#imports
The first part makes sense:
# Imports should usually be on separate lines:
# Correct:
import os
import sys
# Wrong:
import sys, os
But then it goes on to say:
# It's okay to say this though:
# Correct:
from subprocess import Popen, PIPE
How should we interpret this? subprocess
is a module, so is PEP8 saying it's just OK to import multiple things from a single module on one line? Or is it saying it's OK to import any number of things from a higher level entity on one line? I.e. is importing multiple modules from a package good style?
I'm sure arguments could be made for either style, so I'm not asking for opinions on that, but is there an authoritative source on what the PEP8 intent is here?
来源:https://stackoverflow.com/questions/62087225/what-is-the-pep8-recommendation-for-multiple-imports-from-a-package