KnowledgeBoat Logo

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