Context Managers

mediumpy_functional

Implement three context managers (with @contextlib.contextmanager):

  • supresser(*types_) — suppress exceptions whose type is listed (the block exits normally); other exceptions propagate.
  • retyper(type_from, type_to) — catch type_from and re-raise it as type_to, preserving the exception's args.
  • dumper(stream=None) — on any exception, write its message to stream (default sys.stderr), then re-raise.

Your solution

Edit supresser and run the real pytest suite in your browser — no install required. Your code is saved locally.

⌘/Ctrl + ↵

Loading the Python runtime (first run only)…

Hints

Hint 1

Use @contextlib.contextmanager: put `yield` inside a try/except so the with-body runs at the yield.

Hint 2

supresser swallows listed types; retyper raises type_to(*e.args) from the caught error; dumper prints then re-raises.

Stuck? Try these first

easyIterator Warm-up