<div><h4id="functionscannotbevaluessotheymustbewrapped">Functions can not be values, so they must be wrapped:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> functools <spanclass="hljs-keyword">import</span> partial
<div><h4id="userdefinedfunctionscannotbevaluessotheymustbewrapped">User-defined functions can not be values, so they must be wrapped:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> functools <spanclass="hljs-keyword">import</span> partial
LogicOp = Enum(<spanclass="hljs-string">'LogicOp'</span>, {<spanclass="hljs-string">'AND'</span>: partial(<spanclass="hljs-keyword">lambda</span> l, r: l <spanclass="hljs-keyword">and</span> r),
LogicOp = Enum(<spanclass="hljs-string">'LogicOp'</span>, {<spanclass="hljs-string">'AND'</span>: partial(<spanclass="hljs-keyword">lambda</span> l, r: l <spanclass="hljs-keyword">and</span> r),
<spanclass="hljs-string">'OR'</span> : partial(<spanclass="hljs-keyword">lambda</span> l, r: l <spanclass="hljs-keyword">or</span> r)})
<spanclass="hljs-string">'OR'</span> : partial(<spanclass="hljs-keyword">lambda</span> l, r: l <spanclass="hljs-keyword">or</span> r)})
</code></pre></div>
</code></pre></div>
<ul>
<ul>
<li><strong>Another solution in this particular case, is to use <codeclass="python hljs"><spanclass="hljs-string">'and_'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'or_'</span></code> functions from module <ahref="#operator">operator</a>.</strong></li>
<li><strong>Another solution in this particular case is to use built-in functions<codeclass="python hljs"><spanclass="hljs-string">'and_'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'or_'</span></code> from the module <ahref="#operator">operator</a>.</strong></li>
<div><h4id="usefulbuiltinexceptions">Useful built-in exceptions:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">raise</span> TypeError(<spanclass="hljs-string">'Argument is of wrong type!'</span>)
<spanclass="hljs-keyword">raise</span> ValueError(<spanclass="hljs-string">'Argument is of right type but inappropriate value!'</span>)
<spanclass="hljs-keyword">raise</span> RuntimeError(<spanclass="hljs-string">'None of above!'</span>)
+-- UnicodeError # Raised when encoding/decoding strings from/to bytes fails.
+-- UnicodeError # Raised when encoding/decoding strings from/to bytes fails.
</code></pre></div>
</code></pre></div>
<div><h4id="usefulbuiltinexceptions">Useful built-in exceptions:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">raise</span> TypeError(<spanclass="hljs-string">'Argument is of wrong type!'</span>)
<spanclass="hljs-keyword">raise</span> ValueError(<spanclass="hljs-string">'Argument is of right type but inappropriate value!'</span>)
<spanclass="hljs-keyword">raise</span> RuntimeError(<spanclass="hljs-string">'None of above!'</span>)
</code></pre></div>
<div><h4id="collectionsandtheirexceptions">Collections and their exceptions:</h4><pre><codeclass="text language-text">+-----------+------------+------------+------------+
<div><h4id="collectionsandtheirexceptions">Collections and their exceptions:</h4><pre><codeclass="text language-text">+-----------+------------+------------+------------+