Skip to content

Lookups

Lookups finds available Python objects by type and lets you observe changes in what an application exposes.


Find your first objects Install Lookups

Find an object by type
from lookups import fixed

available = fixed("Preview", 42)
print(available.lookup(str))

A query returns an object matching the searched type, or None when none is available. Several objects can match the same type. The lookup model explains how owners expose objects and consumers find them.

Choose a source

Every lookup offers the same type-based query interface. The source determines which objects are available and how that availability can change. Fixed membership keeps the same objects in the lookup without freezing the objects themselves.

  • Generic — changing membership

    Use GenericLookup with InstanceContent when the owner needs to add or remove objects as the application runs.

    Manage membership

  • Fixed / simple — a known collection

    Use fixed(*objects) for objects chosen at construction. With several members, the factory selects SimpleLookup and preserves their supplied order.

    Fixed lookups

  • Singleton — one object

    Use singleton(obj) to expose one existing object through the lookup interface.

    Singleton lookup

  • Empty — no objects

    Use fixed() or EmptyLookup() where a lookup is required but nothing is available.

    Empty lookup

  • Proxy — several sources together

    Use ProxyLookup to combine sources, such as document-specific objects and application-wide objects.

    Combine lookups

  • Delegated — one selected source

    Use DelegatedLookup to follow a provider's lookup. After changing the supplied source, call lookup_updated() to refresh the outer lookup.

    Switch sources

  • Entry point — package contributions

    Use EntryPointLookup to load a named group of installed package contributions. It constructs all contributions immediately and keeps fixed membership.

    Discover package contributions

Explore the documentation

For the background to the library, see Project origins.

Lookups supports CPython 3.11–3.15 and follows Semantic Versioning. The experimental package is excluded from its compatibility guarantees.