-
Notifications
You must be signed in to change notification settings - Fork 0
contextlib
jasper-zanjani edited this page Aug 6, 2020
·
1 revision
Build a context manager out of generator functions - function it decorates must run exactly twice (typically try ... yield finally ...
structure) - yield
can pass a value back (can be assigned to variable after as
keyword)\
@contextmanager
capsys fixture
- from pytest allows access to stdout/stderr output generated during text execution
contextlib.redirect_stdout
- context manager temporarily redirects sys.stdout
to another file or file-like object
- argparse ?
- array ?
- asyncio ?
- bisect ?
- csv ?
- ctypes ?
- curses ?
- datetime ?
- functools ?
- getpass ?
- glob ?
- heapq ?
- http ?
- json ?
- logging ?
- optparse ?
- os ?
- pathlib ?
- platform ?
- pythonnet ?
- random ?
- socket ?
- subprocess ?
- sqlite3 ?
- sys ?
- termcolor ?
- threading ?
- trace ?
- typing ?
- unittest ?
- urllib ?
- venv ?
- weakref ?
- winrm ?