@ -1025,6 +1025,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
<ul>
<li><strong>For arbitrary type use <codeclass="python hljs"><spanclass="hljs-string">'typing.Any'</span></code>.</strong></li>
<li><strong>Objects can be made sortable with <codeclass="python hljs"><spanclass="hljs-string">'order=True'</span></code> and immutable with <codeclass="python hljs"><spanclass="hljs-string">'frozen=True'</span></code>.</strong></li>
<li><strong>For object to be hashable, all attributes must be hashable and frozen must be True.</strong></li>
<li><strong>Function field() is needed because <codeclass="python hljs"><spanclass="hljs-string">'<attr_name>: list = []'</span></code> would make a list that is shared among all instances.</strong></li>
<div><h4id="userdefinedfunctionscannotbevaluessotheymustbewrapped">User-defined functions cannot 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),
<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>
<ul>
<li><strong>Another solution in this particular case is to use functions and_() and or_() from the module <ahref="#operator">operator</a>.</strong></li>
<li><strong>Member names are in all caps because trying to access a member that is named after a reserved keyword raises SyntaxError.</strong></li>
<li><strong>Code inside the <codeclass="python hljs"><spanclass="hljs-string">'else'</span></code> block will only be executed if <codeclass="python hljs"><spanclass="hljs-string">'try'</span></code> block had no exceptions.</strong></li>
<li><strong>Code inside the <codeclass="python hljs"><spanclass="hljs-string">'finally'</span></code> block will always be executed.</strong></li>
<li><strong>Code inside the <codeclass="python hljs"><spanclass="hljs-string">'finally'</span></code> block will always be executed (unless a signal is received).</strong></li>
<div><h2id="introspection"><ahref="#introspection"name="introspection">#</a>Introspection</h2><p><strong>Inspecting code at runtime.</strong></p><div><h3id="variables">Variables</h3><pre><codeclass="python language-python hljs"><list> = dir() <spanclass="hljs-comment"># Names of local variables (incl. functions).</span>