value = <dict>.pop(key) <spanclass="hljs-comment"># Removes item or raises KeyError.</span>
value = <dict>.pop(key) <spanclass="hljs-comment"># Removes item or raises KeyError if missing.</span>
{k <spanclass="hljs-keyword">for</span> k, v <spanclass="hljs-keyword">in</span><dict>.items() <spanclass="hljs-keyword">if</span> v == value} <spanclass="hljs-comment"># Returns set of keys that point to the value.</span>
{k <spanclass="hljs-keyword">for</span> k, v <spanclass="hljs-keyword">in</span><dict>.items() <spanclass="hljs-keyword">if</span> v == value} <spanclass="hljs-comment"># Returns set of keys that point to the value.</span>
{k: v <spanclass="hljs-keyword">for</span> k, v <spanclass="hljs-keyword">in</span><dict>.items() <spanclass="hljs-keyword">if</span> k <spanclass="hljs-keyword">in</span> keys} <spanclass="hljs-comment"># Returns a dictionary, filtered by keys.</span>
{k: v <spanclass="hljs-keyword">for</span> k, v <spanclass="hljs-keyword">in</span><dict>.items() <spanclass="hljs-keyword">if</span> k <spanclass="hljs-keyword">in</span> keys} <spanclass="hljs-comment"># Returns a dictionary, filtered by keys.</span>
</code></pre>
</code></pre>
@ -729,7 +729,7 @@ player = Player(point, direction) <span class="hljs-comment">#
</code></pre>
</code></pre>
<ul>
<ul>
<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>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>
<li><strong>A few examples being: <codeclass="python hljs"><spanclass="hljs-string">'defaultdict(<func>)'</span></code>, <codeclass="python hljs"><spanclass="hljs-string">'iter(<func>, to_exc)'</span></code> and dataclass's <codeclass="python hljs"><spanclass="hljs-string">'field(default_factory=<func>)'</span></code>.</strong></li>
</ul>
</ul>
<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>
<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>