A context manager can be used to initialize and finalize resources. Once
defined, they can be used with Python's with construct.
context.py: illustrates two ways to define a context manager,
- as a class, providing hooks on instantiation, entering, and exiting the context.
- as function decorator, where code to be executed for initialization,
entering, and exiting sandwiches a
yieldstatement that returns the value.
The exception is raised on purpose to illustrate exception handling by a context manager.