Bird
0
0

Why is it better to import specific items rather than using from module import *?

hard📝 Conceptual Q10 of 15
Python - Modules and Code Organization
Why is it better to import specific items rather than using from module import *?
AIt avoids polluting the namespace and improves code clarity
BIt imports all items faster
CIt automatically imports submodules
DIt prevents any import errors
Step-by-Step Solution
Solution:
  1. Step 1: Understand what import * does

    It imports all public names, which can clutter the namespace.
  2. Step 2: Benefits of importing specific items

    Importing specific items keeps namespace clean and makes code easier to read.
  3. Final Answer:

    It avoids polluting the namespace and improves code clarity -> Option A
  4. Quick Check:

    Specific import = cleaner namespace [OK]
Quick Trick: Import only what you need to keep code clean [OK]
Common Mistakes:
  • Thinking import * is faster
  • Believing import * prevents errors
  • Assuming import * imports submodules automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes