Verified Commit e4cb5e1b authored by Renato Alves's avatar Renato Alves 🌱
Browse files

Call the generator/context manager in the right place

parent 8302c3ba
......@@ -1403,13 +1403,13 @@ def with_before_and_after(*args, **kwargs):
yield "A MESSAGE!!!"
print("<<< after <<<")
managed = contextmanager(with_before_and_after)()
managed = contextmanager(with_before_and_after)
~~~
{: .language-python}
> ## Decorating functions
>
> If you are finding the line `contextmanager(with_before_and_after)()` puzzling
> If you are finding the line `contextmanager(with_before_and_after)` puzzling
> you may have seen its other face called [**decorator**][decorator].
>
> In fact, the above code is equivalent to:
......@@ -1424,7 +1424,7 @@ managed = contextmanager(with_before_and_after)()
This function can then be used as:
~~~
with managed as msg:
with managed() as msg:
print("OMG! I have received", msg)
~~~
{: .language-python}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment