What is the difference between these import statements?

x otikoruk x

I have seen many online examples with different ways of importing modules. I was wondering what the difference is, if it is in speed, accuracy, priority, or psychology.

The first, and most common is;

import sys
import os
import socket
import shutil
import threading
import urllib
import time
import zipfile

I understand the methodry, but this seems unnecessary when you can use, like I personally do;

import sys, os, socket, shutil, threading, urllib, time, zipfile

Less lines, less code, less headaches, at least in my opinion. However, the third one stumps me;

import sys, os, shutil
import threading
import zipfile
import socket, urllib
import time

What is the point or purpose of that method of importing? I would think that it would be inconvenient to mix the first two methods, as well as cluttered. It also seems like it would be slower than either method, or in worst case scenario, slower than both combined.

So, like I was wondering, what's the difference between the three?

Is there any logic in the third one, like a speed increase, or is it just for looks?

Zack Tanner

Functionally, they do the same thing. It's a style preference. Many people adhere to the PEP-8 style guidelines (ref: https://www.python.org/dev/peps/pep-0008/#imports) which state that imports should be on separate lines.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What is the difference between these if statements?

What is the difference between with and without curly bracket notation in export/import statements?

What the difference between these generics statements?

What is the difference between "As" and "=" in TSQL SELECT statements?

What's the difference between these two statements in Javascript?

In Ruby what is the difference between different rescue statements?

What's the semantical difference between the two statements?

What is the difference between these two java statements?

What is the difference between these two sql statements(JDBC)?

What is the difference between ( for... in ) and ( for... of ) statements in JavaScript?

what's the difference between the two statements?

What is the difference between Expressions and Statements in Scala

what is the difference between these 2 sql statements

What is the difference between the following two assignment statements?

What is the difference between the following npm install statements?

What's the difference between '==' and 'in' in if conditional statements?

what is the difference between value and invalue statements in SAS?

What is the difference between these two regular expression statements

Benefit Of Repository and what is difference between two statements

what is the difference between these two statements in R?

What is the difference between function and keyword/statements?

What is the difference between these two print statements in Perl? And what is the if statement doing?

What's the difference between loadfile, require, and import

What is the difference between "import" of framework and "linking" with framework?

What is the difference between #import and #include in C?

What is the difference between Clone and Import in Build definition?

What is the difference between declarations, providers, and import in NgModule?

What is the difference between import and load in Docker?

In GHCi, what is the difference between ':module' and 'import'?

TOP Ranking

HotTag

Archive