64749

What is the PEP8 recommendation for multiple imports from a package?

<h3>Question</h3>

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

Recommend

  • Not awaitable method exception thowing inconsistent behaviour
  • How To Align Text Inside SVG In D3.js
  • Efficiency & speedup of parallel vs. serial
  • Make a List from a Tuple List on F#
  • is there any limit for using window.open() in javascript
  • JQuery return a function to a variable
  • instanceof yields inconsistent results for detecting interfaces?
  • Improving Cython Lapack performance with internal array definitions?
  • spark streaming write data to Hbase with python blocked on saveAsNewAPIHadoopDataset
  • CanJS add custom MODEL method
  • Drag file into Access, how to check the file details?
  • Google API Level 18 emulator “This app won't run unless you update Google Play services”
  • Auto-incrementation with HSQLDB (2.2.8) + DDLUtils
  • RSRuntimeException: Loading of ScriptC script failed (build tools 19.0.2)
  • Android sharing intent with google maps location and URL Shortener API
  • flexbox sticky footer
  • How do I add a trailing slash for Django MPTT-based categorization app?
  • .Net how to set IsReadOnly for a property for a usercontrol
  • Docker build error: “could not connect to server” (behind proxy)
  • 3 transitions, pausetime between transitions
  • Null Space Binary Matrix : Java
  • android 3G signal strength
  • Storing the Cursor for App Engine Pagination
  • Finding all XML nodes between each two processing instructions
  • MFMailComposer send email without presenting view
  • Facebook friend list in Facebook Android SDK 3.14
  • Unable to run testNG tests from maven
  • Adding horizontal slider to QTableWidget
  • playing mp3 from nsbundle
  • Julia 1.0 UndefVarError - Scope of Variable
  • What are advantages/disadvantages of using Selenium for Java vs .NET applications?
  • Ajax call on Multiple selection in Select box
  • how to run a different select statement based on condition in Hive SQL
  • Add font awesome icon to custom add to cart button in Woocommerce 3
  • How to merge objects within array based on attribute
  • How to restrict use of third party camera app from your app
  • Python 3x- Compression Makes File Bigger :(
  • how to get the location(lat/lng) on google maps v3 from the location(x,y)
  • Python Flask - GUI for client