Explain the difference between import and from import statement . With example?
Answers
Answered by
3
Answer:
Importing the module doesn't waste anything; the module is always fully imported (into the sys. modules mapping), so wether you use import sys or from sys import argv makes no odds. The only difference between the two statements is what name is bound; import sys binds the name sys to the module (so sys -> sys. ... argv ).
Answered by
6
Explanation:
The only difference between the two statements is what name is bound; import sys binds the name sys to the module (so sys -> sys. modules['sys'] ), while from sys import argv binds a different name, argv , pointing straight at the attribute contained inside of the module (so argv -> sys. modules['sys']. argv ).
FOLLOW ME
Similar questions