diff options
| author | J08nY | 2024-05-27 12:17:27 +0200 |
|---|---|---|
| committer | J08nY | 2024-05-27 12:17:27 +0200 |
| commit | cdba24efe7db53846cdec1cc15b4c4f01be90336 (patch) | |
| tree | 537ede3c8694b15bdffd3e7881a0cc772fa4d1f7 | |
| parent | 5114fea31c619dae178893617d51af3eecad34f2 (diff) | |
| download | pyecsca-cdba24efe7db53846cdec1cc15b4c4f01be90336.tar.gz pyecsca-cdba24efe7db53846cdec1cc15b4c4f01be90336.tar.zst pyecsca-cdba24efe7db53846cdec1cc15b4c4f01be90336.zip | |
More docs for local contextmanager.
| -rw-r--r-- | pyecsca/ec/context.py | 10 |
1 files changed, 9 insertions, 1 deletions
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. """ |
