<div><h4id="sometypesdonothavebuiltinnamessotheymustbeimported">Some types do not have built-in names, so they must be imported:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> types <spanclass="hljs-keyword">import</span> FunctionType, MethodType, LambdaType, GeneratorType
<div><h4id="sometypesdonthavebuiltinnamessotheymustbeimported">Some types don't have built-in names, so they must be imported:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> types <spanclass="hljs-keyword">import</span> FunctionType, MethodType, LambdaType, GeneratorType
</code></pre></div>
<div><h3id="abstractbaseclasses">Abstract Base Classes</h3><p><strong>Each abstract base class specifies a set of virtual subclasses. These classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span><spanclass="hljs-keyword">from</span> collections.abc <spanclass="hljs-keyword">import</span> Sequence, Collection, Iterable
<li><strong>Partial is also useful in cases when function needs to be passed as an argument, because it enables us to set its arguments beforehand.</strong></li>
<li><strong>A few examples being: <codeclass="python hljs"><spanclass="hljs-string">'defaultdict(<function>)'</span></code>, <codeclass="python hljs"><spanclass="hljs-string">'iter(<function>, to_exclusive)'</span></code> and dataclass's <codeclass="python hljs"><spanclass="hljs-string">'field(default_factory=<function>)'</span></code>.</strong></li>
</ul>
<div><h3id="nonlocal">Nonlocal</h3><p><strong>If variable is being assigned to anywhere in the scope, it is regarded as a local variable, unless it is declared as a 'global' or a 'nonlocal'.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-function"><spanclass="hljs-keyword">def</span><spanclass="hljs-title">get_counter</span><spanclass="hljs-params">()</span>:</span>
<div><h3id="nonlocal">Non-Local</h3><p><strong>If variable is being assigned to anywhere in the scope, it is regarded as a local variable, unless it is declared as a 'global' or a 'nonlocal'.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-function"><spanclass="hljs-keyword">def</span><spanclass="hljs-title">get_counter</span><spanclass="hljs-params">()</span>:</span>