What is the difference between import module and from module import * in terms of namespace pollution?
- Both have the same impact
- from module import * is risky
- from module import * is safer
- import module is safer
Using from module import * pollutes the current namespace by bringing all symbols from the module into the current scope. This can lead to name clashes and make the code less maintainable. Importing module directly doesn't introduce symbols to the current namespace.
Loading...
Related Quiz
- Which Python web framework uses the “Don’t repeat yourself” principle?
- How would you create a try block that catches both ValueError and TypeError exceptions?
- You are developing an application that requires the implementation of a map (or dictionary) data structure with ordered keys. Which advanced data structure would be most suitable to use for the implementation?
- You have two sets, one containing all employees who attended a training session and another with employees who completed an online assessment. You want to find out who attended the training but did not complete the assessment. Which set operation would help?
- In RESTful API development, what does the acronym CRUD stand for?