|
|
@ -366,7 +366,7 @@ Point(x=<span class="hljs-number">1</span>, y=<span class="hljs-number">2</span> |
|
|
|
</ul> |
|
|
|
<div><h2 id="format"><a href="#format" name="format">#</a>Format</h2><pre><code class="python language-python hljs"><str> = <span class="hljs-string">f'<span class="hljs-subst">{<el_1>}</span>, <span class="hljs-subst">{<el_2>}</span>'</span> <span class="hljs-comment"># Curly brackets can also contain expressions.</span> |
|
|
|
<str> = <span class="hljs-string">'{}, {}'</span>.format(<el_1>, <el_2>) <span class="hljs-comment"># Or: '{0}, {a}'.format(<el_1>, a=<el_2>)</span> |
|
|
|
<str> = <span class="hljs-string">'%s, %s'</span> % (<el_1>, <el_2>) <span class="hljs-comment"># Redundant and inferior C style formatting.</span> |
|
|
|
<str> = <span class="hljs-string">'%s, %s'</span> % (<el_1>, <el_2>) <span class="hljs-comment"># Redundant and inferior C-style formatting.</span> |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
<div><h3 id="attributes">Attributes</h3><pre><code class="python language-python hljs"><span class="hljs-meta">>>> </span>Person = collections.namedtuple(<span class="hljs-string">'Person'</span>, <span class="hljs-string">'name height'</span>) |
|
|
@ -2160,7 +2160,7 @@ drawer = cg.output.GraphvizOutput(output_file=filename) |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code class="python language-python hljs"><array> = np.array(<list/list_of_lists>) <span class="hljs-comment"># Returns 1d/2d NumPy array.</span> |
|
|
|
<pre><code class="python language-python hljs"><array> = np.array(<list/list_of_lists>) <span class="hljs-comment"># Returns a 1d/2d NumPy array.</span> |
|
|
|
<array> = np.zeros/ones(<shape>) <span class="hljs-comment"># Also np.full(<shape>, <el>).</span> |
|
|
|
<array> = np.arange(from_inc, to_exc, ±step) <span class="hljs-comment"># Also np.linspace(start, stop, num).</span> |
|
|
|
<array> = np.random.randint(from_inc, to_exc, <shape>) <span class="hljs-comment"># Also np.random.random(<shape>).</span> |
|
|
|