Skip to main content

firstmethod

Multiple dispatch.

Return a function that with a list of instances,
finds the first instance that gives a value for the given method.

The list can also contain lazy instances
(:class:`~kombu.utils.functional.lazy`.)
def firstmethod(
method: string,
on_call: callable = None
) - > function

Multiple dispatch. Return a function that with a list of instances, finds the first instance that gives a value for the given method.

Parameters

NameTypeDescription
methodstringThe name of the method to look for and invoke on each instance in the provided list.
on_callcallable = NoneAn optional wrapper function used to invoke the found method; receives the method and its arguments.

Returns

TypeDescription
functionA matcher function that iterates over objects and returns the first non-None result from the specified method.