with_global¶
- guppyft.globals.with_global(initial_state: G, callback_func: Callable[[P], tuple[Unpack[R]] | Ret], *args: P, **kwargs: P) tuple[G, Unpack[R]] | tuple[G, Ret]¶
Call the given Guppy function in a context where the global state is available through
map_global()calls (seemap_global()for more context).Note: All calls to this function will currently use the same global variable name to store and provide the global state.
- Parameters:
initial_state – The initial state of the global variable.
callback_func – The function to call in the global-enabled context.
args – Regular arguments to pass to the function.
kwargs – Keyword arguments to pass to the function.
- Returns:
A tuple containing the final global state followed by the value(s) returned by the called function.