How do modules, packages and `__init__.py` work?
BeginnerConceptLanguage essentials & functions
Answer
A module is a .py file. A package is a directory of modules, traditionally marked with __init__.py (which runs on import and can re-export names). Without __init__.py you get a namespace package, which works but can confuse tools.
import cloudaudit.checks searches sys.path: the script's directory (or current directory), PYTHONPATH, then site-packages. Prefer absolute imports inside an installed package and use the src/ layout so tests import the installed package, not a stray local folder.
More on Language essentials & functions
Why is Python the default scripting language in so many DevOps teams, and where would you not use it?BeginnerWhat is the difference between mutable and immutable types? Give examples.BeginnerWhat does assignment do in Python, and how do shallow and deep copies differ?BeginnerExplain the mutable default argument bug and how to fix it.IntermediateWhat is the difference between `==` and `is`?BeginnerWhat values are "falsy" in Python, and why does it matter in scripts?Beginner