Hard Programming & OOP Python Programming
Explain Python's import system and how modules are loaded.
Answer
Import process: check sys.modules cache, find module (finders), load module (loaders). Finders: meta_path finders (first), path_based (sys.path). Built-in finder, frozen finder, path finder. Module types: built-in, frozen, packages, namespace packages. __import__ underlies import statement. importlib for programmatic imports. Circular imports: avoided if imports at function level or import module (not from). Package __init__.py executed on import. __all__ controls 'from X import *'. Relative imports in packages. Loader creates module object, exec module code. sys.path_hooks for custom loaders.
IIT Certified
Master These Concepts with IIT Certification
175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.
Relevant for Roles
Senior Python Developer Framework Developer Build Engineer