Modules
When working with modules, it's important to remember that classes can be imported directly from the module, rather than importing the entire module. As you learned in Chapter 2, Data Types and Modules, in the Types of imports section, import calls other libraries or modules, while from is a selective import, allowing you to get specific parts of a module; using from foo import * is dangerous, as it imports everything into the current namespace, which can cause shadowing of different objects, resulting in errors. Classes and functions are the tools that make importation work.
Since everything in Python is (from the interpreter's viewpoint) an object, everything can be imported. However, in practice, only classes and functions can ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access