with_global¶
- guppyft.globals.with_global(initial_state: ~guppyft.globals.G, callback_func: ~collections.abc.Callable[[~P], tuple[~typing.Unpack[R]]], *args: ~typing.~P, **kwargs: ~typing.~P) tuple[G, Unpack[R]][source]¶
- guppyft.globals.with_global(initial_state: ~guppyft.globals.G, callback_func: ~collections.abc.Callable[[~P], ~guppyft.globals.Ret], *args: ~typing.~P, **kwargs: ~typing.~P) tuple[G, Ret]
Call a Guppy function in a context where
map_global()provides global state.Note
All calls to this function currently use the same global variable name to store and provide global state.
- Parameters:
initial_state – The initial state of the global variable.
callback_func – The function to call in the global-enabled context.
*args – Positional 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 or values returned by the called function.