from Import names from module
Last updated: 2026-09-22
from Import names from module
from module import name imports specific names from a module.
| Category | Keywords & Statements |
|---|---|
| Kind | Keyword / Statement |
| Python Version | all |
📝 Syntax
from module import name [, name]*
from module import *
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
3.0 8.0
🏷️ Related Keywords / Statements
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QWhy is `from module import *` discouraged?
AIt imports every name in the module that does not start with an underscore, which may silently overwrite variables or functions you already have and hurts readability and maintainability. List the names you want explicitly instead.
QAfter `from math import sqrt`, can I still use `math` directly?
ANo. `from ... import` only binds the name `sqrt` into the current namespace; `math` itself is not bound. If you still need other `math` functions, write `import math`.
QWhat does the error «attempted relative import with no known parent package» mean?
AIt appears when you use a relative import (`from . import x`) inside a module that is not being imported as part of a package (for example when run directly as a script). Use an absolute import (`from pkg import module`) in the top-level script.