Answer the question
In order to leave comments, you need to log in
What is the difference of importing libraries (import *)?
Hello.
Got a question.
What is the key difference between these import methods?
What will be imported and under what names?
from xml.dom import minidom
from xml.dom.minidom import *
Answer the question
In order to leave comments, you need to log in
I really liked the explanation that was given in the course at CodeAcademy, if my memory serves me right. There it was.
You sit in a room and do something, and the boxes (modules) with tools (functions) are in another room. You also have an assistant (interpreter) who brings you boxes and tools from another room. You can ask for it in 3 ways.
1. import box
Bring me a box, I will take the necessary tools from it
2. from box import tool
Bring me a tool from the box, I will use it without getting into the box
3. from box import *
Bring me a box and get all the tools out of it
In general, in large projects better to use 1 (or 2) and try to avoid 3.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question