Computer Science
Why should the from <module> import <object> statement be avoided to import objects ?
Python Libraries
5 Likes
Answer
The from <module> import <object> statement should be avoided to import objects because it imports objects directly into the current namespace. If a program already has a variable or function with the same name as the one imported via the module, the imported object will overwrite the existing variable or function, leading to potential name clashes because there cannot be two variables with the same name in one namespace.
Answered By
2 Likes
Related Questions
Name the Python Library modules which need to be imported to invoke the following functions :
(i) log()
(ii) pow()
(iii) cos
(iv) randint
(v) sqrt()
What is dot notation of referring to objects inside a module ?
What do you understand by standard library of Python ?
Explain the difference between
import <module>
andfrom <module> import
statements, with examples.