Code

Your Public API

Every name in a module can be imported, but not every name is a promise. Python marks the difference with two conventions:

  • A leading underscore (_helper) means "internal, may change without warning".
  • __all__ lists the public names. It controls from module import * and tells readers, docs tools and linters what your API is.
# lantern_tools/__init__.py
from .core import light, dim
from ._colors import _blend   # internal

__all__ = ["light", "dim"]

Packages often re-export names in __init__.py, so users can write from lantern_tools import light without knowing which file it lives in. That gives you freedom to reorganize your files later without breaking anyone.

Without __all__, a star import grabs every name that doesn't start with _, including modules you imported, like re.

Assignment

The program writes a module lanternkit.py to the virtual disk. Edit the module's source text (inside the ''' quotes):

  1. Rename the helper clean_color to _clean_color, everywhere it's used.
  2. Set __all__ to ["VERSION", "light"].