From cdba24efe7db53846cdec1cc15b4c4f01be90336 Mon Sep 17 00:00:00 2001 From: J08nY Date: Mon, 27 May 2024 12:17:27 +0200 Subject: More docs for local contextmanager. --- pyecsca/ec/context.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pyecsca/ec/context.py b/pyecsca/ec/context.py index 7167e32..feac713 100644 --- a/pyecsca/ec/context.py +++ b/pyecsca/ec/context.py @@ -150,7 +150,8 @@ class Context(ABC): Context is an object that traces actions which happen. There is always one context active, see functions :py:func:`getcontext`, - :py:func:`setcontext` and :py:func:`resetcontext`. + :py:func:`setcontext` and :py:func:`resetcontext`. Also, the :py:func:`local` + contextmanager. """ @abstractmethod @@ -263,6 +264,13 @@ def local(ctx: Optional[Context] = None) -> ContextManager: """ Use a local context. + Use it like a contextmanager, the context is active during its execution. + >>> with local(DefaultContext()) as ctx: + ... with Action() as action: + ... pass + >>> list(ctx.actions)[0] == action + True + :param ctx: If none, current context is copied. :return: A context manager. """ -- cgit v1.3.1