@@ -320,10 +320,10 @@ Context Managers
320320----------------
321321
322322A context manager is a Python object that provides extra contextual information
323- to an action. This extra information takes the form of running a function upon
324- initiating the context using the ``with `` statement as well as running a function
323+ to an action. This extra information takes the form of running a callable upon
324+ initiating the context using the ``with `` statement, as well as running a callable
325325upon completing all the code inside the ``with `` block. The most well known
326- example of using a context manager is operating on a file:
326+ example of using a context manager is shown here, opening on a file:
327327
328328.. code-block :: python
329329
@@ -332,7 +332,7 @@ example of using a context manager is operating on a file:
332332
333333 Anyone familiar with this pattern knows that invoking ``open `` in this fashion
334334ensures that ``f ``'s ``close `` method will be called at some point. This reduces
335- a developer's cognitive load and makes code easier to read.
335+ a developer's cognitive load and makes the code easier to read.
336336
337337There are two easy ways to implement this functionality yourself: using a class
338338or using a generator. Let's implement the above functionality ourselves, starting
@@ -359,7 +359,7 @@ by the ``with`` statement. CustomOpen is first instantiated and then its
359359``f `` in the ``as f `` part of the statement. When the contents of the ``with `` block
360360is finished executing, the ``__exit__ `` method is then called.
361361
362- And now the generator approach using Python's own
362+ And now the generator approach using Python's own
363363`contextlib <https://docs.python.org/2/library/contextlib.html >`_:
364364
365365.. code-block :: python
0 commit comments