<li><strong>Partial is also useful in cases when a 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>
<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>
</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">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>