<div dir="ltr"><dt id="term-context-manager" style="font-weight:bold;font-size:1.1em;font-family:"Lucida Grande",Arial,sans-serif">context manager</dt><dd style="margin-top:3px;margin-bottom:10px;margin-left:30px;text-align:justify;line-height:20.8px;font-family:"Lucida Grande",Arial,sans-serif;font-size:16px">An object which controls the environment seen in a <a class="" href="https://docs.python.org/3.6/reference/compound_stmts.html#with" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">with</span></code></a> statement by defining <a class="" href="https://docs.python.org/3.6/reference/datamodel.html#object.__enter__" title="object.__enter__" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">__enter__()</span></code></a> and <a class="" href="https://docs.python.org/3.6/reference/datamodel.html#object.__exit__" title="object.__exit__" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">__exit__()</span></code></a> methods. See <span class="" id="index-5"></span><a class="" href="https://www.python.org/dev/peps/pep-0343" style="color:rgb(99,99,187);text-decoration:none"><strong>PEP 343</strong></a>.</dd><dt id="term-coroutine" style="font-weight:bold;font-size:1.1em;font-family:"Lucida Grande",Arial,sans-serif">coroutine</dt><dd style="margin-top:3px;margin-bottom:10px;margin-left:30px;text-align:justify;line-height:20.8px;font-family:"Lucida Grande",Arial,sans-serif;font-size:16px">Coroutines is a more generalized form of subroutines. Subroutines are entered at one point and exited at another point. Coroutines can be entered, exited, and resumed at many different points. They can be implemented with the <a class="" href="https://docs.python.org/3.6/reference/compound_stmts.html#async-def" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">async</span> <span class="">def</span></code></a> statement. See also <span class="" id="index-7"></span><a class="" href="https://www.python.org/dev/peps/pep-0492" style="color:rgb(99,99,187);text-decoration:none"><strong>PEP 492</strong></a>.</dd><dt id="term-coroutine-function" style="font-weight:bold;font-size:1.1em;font-family:"Lucida Grande",Arial,sans-serif">coroutine function</dt><dd style="margin-top:3px;margin-bottom:10px;margin-left:30px;text-align:justify;line-height:20.8px;font-family:"Lucida Grande",Arial,sans-serif;font-size:16px">A function which returns a <a class="" href="https://docs.python.org/3.6/glossary.html#term-coroutine" style="color:rgb(99,99,187);text-decoration:none">coroutine</a> object. A coroutine function may be defined with the <a class="" href="https://docs.python.org/3.6/reference/compound_stmts.html#async-def" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">async</span> <span class="">def</span></code></a> statement, and may contain <a class="" href="https://docs.python.org/3.6/reference/expressions.html#await" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">await</span></code></a>, <a class="" href="https://docs.python.org/3.6/reference/compound_stmts.html#async-for" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">async</span> <span class="">for</span></code></a>, and <a class="" href="https://docs.python.org/3.6/reference/compound_stmts.html#async-with" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">async</span> <span class="">with</span></code></a> keywords. These were introduced by <span class="" id="index-8"></span><a class="" href="https://www.python.org/dev/peps/pep-0492" style="color:rgb(99,99,187);text-decoration:none"><strong>PEP 492</strong></a>.</dd><dt id="term-decorator" style="font-weight:bold;font-size:1.1em;font-family:"Lucida Grande",Arial,sans-serif">decorator</dt><dd style="margin-top:3px;margin-bottom:10px;margin-left:30px;text-align:justify;line-height:20.8px;font-family:"Lucida Grande",Arial,sans-serif;font-size:16px"><p class="" style="line-height:22.4px;margin-top:0px!important">A function returning another function, usually applied as a function transformation using the <code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:rgb(236,240,243)"><span class="">@wrapper</span></code> syntax. Common examples for decorators are <a class="" href="https://docs.python.org/3.6/library/functions.html#classmethod" title="classmethod" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">classmethod()</span></code></a> and<a class="" href="https://docs.python.org/3.6/library/functions.html#staticmethod" title="staticmethod" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">staticmethod()</span></code></a>.</p><p style="margin-top:0px;line-height:22.4px">The decorator syntax is merely syntactic sugar, the following two function definitions are semantically equivalent:</p><div class="" style=""><div class="" style="background:rgb(238,255,204)"><pre style="padding:5px;color:rgb(51,51,51);line-height:18.528px;border:1px solid rgb(170,204,153);font-family:monospace,sans-serif;font-size:15.44px;border-radius:3px"><span class="" style="color:rgb(0,112,32);font-weight:bold">def</span> <span class="" style="color:rgb(6,40,126)">f</span><span class="">(</span><span class="" style="color:rgb(102,102,102)">...</span><span class="">):</span>
<span class="" style="color:rgb(102,102,102)">...</span>
<span class="">f</span> <span class="" style="color:rgb(102,102,102)">=</span> <span class="" style="color:rgb(0,112,32)">staticmethod</span><span class="">(</span><span class="">f</span><span class="">)</span>
<span class="" style="color:rgb(85,85,85);font-weight:bold">@staticmethod</span>
<span class="" style="color:rgb(0,112,32);font-weight:bold">def</span> <span class="" style="color:rgb(6,40,126)">f</span><span class="">(</span><span class="" style="color:rgb(102,102,102)">...</span><span class="">):</span>
<span class="" style="color:rgb(102,102,102)">...</span>
</pre></div></div><p class="" style="margin-top:0px;line-height:22.4px">The same concept exists for classes, but is less commonly used there. See the documentation for <a class="" href="https://docs.python.org/3.6/reference/compound_stmts.html#function" style="color:rgb(99,99,187);text-decoration:none">function definitions</a> and <a class="" href="https://docs.python.org/3.6/reference/compound_stmts.html#class" style="color:rgb(99,99,187);text-decoration:none">class definitions</a> for more about decorators.</p></dd><dt id="term-descriptor" style="font-weight:bold;font-size:1.1em;font-family:"Lucida Grande",Arial,sans-serif">descriptor</dt><dd style="margin-top:3px;margin-bottom:10px;margin-left:30px;text-align:justify;line-height:20.8px;font-family:"Lucida Grande",Arial,sans-serif;font-size:16px"><p class="" style="line-height:22.4px;margin-top:0px!important">Any object which defines the methods <a class="" href="https://docs.python.org/3.6/reference/datamodel.html#object.__get__" title="object.__get__" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">__get__()</span></code></a>, <a class="" href="https://docs.python.org/3.6/reference/datamodel.html#object.__set__" title="object.__set__" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">__set__()</span></code></a>, or <a class="" href="https://docs.python.org/3.6/reference/datamodel.html#object.__delete__" title="object.__delete__" style="color:rgb(99,99,187);text-decoration:none"><code class="" style="padding:0px 1px;font-size:15.44px;font-family:monospace,sans-serif;border-radius:3px;background-color:transparent"><span class="">__delete__()</span></code></a>. When a class attribute is a descriptor, its special binding behavior is triggered upon attribute lookup. Normally, using <em>a.b</em> to get, set or delete an attribute looks up the object named <em>b</em> in the class dictionary for <em>a</em>, but if <em>b</em> is a descriptor, the respective descriptor method gets called. Understanding descriptors is a key to a deep understanding of Python because they are the basis for many features including functions, methods, properties, class methods, static methods, and reference to super classes.</p><p class="" style="margin-top:0px;line-height:22.4px">For more information about descriptors’ methods, see <a class="" href="https://docs.python.org/3.6/reference/datamodel.html#descriptors" style="color:rgb(99,99,187);text-decoration:none">Implementing Descriptors</a>.</p></dd></div>