|
@ -1507,7 +1507,7 @@ param_names = list(<sig>.parameters.keys()) |
|
|
<h2 id="metaprograming"><a href="#metaprograming" name="metaprograming">#</a>Metaprograming</h2> |
|
|
<h2 id="metaprograming"><a href="#metaprograming" name="metaprograming">#</a>Metaprograming</h2> |
|
|
<p><strong>Code that generates code.</strong></p> |
|
|
<p><strong>Code that generates code.</strong></p> |
|
|
<h3 id="type-1">Type</h3> |
|
|
<h3 id="type-1">Type</h3> |
|
|
<p><strong>Type is the root class. If only passed the object it returns its type (class). Otherwise it creates a new class.</strong></p> |
|
|
|
|
|
|
|
|
<p><strong>Type is the root class. If only passed an object it returns its type (class). Otherwise it creates a new class.</strong></p> |
|
|
<pre><code class="python language-python hljs"><<span class="hljs-class"><span class="hljs-keyword">class</span>> = <span class="hljs-title">type</span><span class="hljs-params">(<class_name>, <parents_tuple>, <attributes_dict>)</span> |
|
|
<pre><code class="python language-python hljs"><<span class="hljs-class"><span class="hljs-keyword">class</span>> = <span class="hljs-title">type</span><span class="hljs-params">(<class_name>, <parents_tuple>, <attributes_dict>)</span> |
|
|
</span></code></pre> |
|
|
</span></code></pre> |
|
|
<pre><code class="python language-python hljs"><span class="hljs-meta">>>> </span>Z = type(<span class="hljs-string">'Z'</span>, (), {<span class="hljs-string">'a'</span>: <span class="hljs-string">'abcde'</span>, <span class="hljs-string">'b'</span>: <span class="hljs-number">12345</span>}) |
|
|
<pre><code class="python language-python hljs"><span class="hljs-meta">>>> </span>Z = type(<span class="hljs-string">'Z'</span>, (), {<span class="hljs-string">'a'</span>: <span class="hljs-string">'abcde'</span>, <span class="hljs-string">'b'</span>: <span class="hljs-number">12345</span>}) |
|
|