INNER CODE UNIT · Python

__getattr__

faridrashidi/cnsplots · src/cnsplots/plots/__init__.py:85

def __getattr__(name: str):
    """Load a plot function on first access."""
    try:
        module_name, attribute_name = _LAZY_IMPORTS[name]
    except KeyError:
        raise AttributeError(f"module {__name__!r} has no attribute {name!r}") from None

    value = getattr(import_module(module_name), attribute_name)
    globals()[name] = value
    return value


def __dir__() -> list[str]:
    """Return eager and lazy module attributes."""
    return sorted(set(globals()) | set(__all__))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…