|
|
@ -809,6 +809,7 @@ func(*args, **kwargs) |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
<div><h3 id="mapfilterreduce">Map, Filter, Reduce</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> functools <span class="hljs-keyword">import</span> reduce |
|
|
|
|
|
|
|
<iter> = map(<span class="hljs-keyword">lambda</span> x: x + <span class="hljs-number">1</span>, range(<span class="hljs-number">10</span>)) <span class="hljs-comment"># (1, 2, ..., 10)</span> |
|
|
|
<iter> = filter(<span class="hljs-keyword">lambda</span> x: x > <span class="hljs-number">5</span>, range(<span class="hljs-number">10</span>)) <span class="hljs-comment"># (6, 7, 8, 9)</span> |
|
|
|
<obj> = reduce(<span class="hljs-keyword">lambda</span> out, x: out + x, range(<span class="hljs-number">10</span>)) <span class="hljs-comment"># 45</span> |
|
|
@ -1039,6 +1040,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas |
|
|
|
|
|
|
|
|
|
|
|
<div><h3 id="copy">Copy</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> copy <span class="hljs-keyword">import</span> copy, deepcopy |
|
|
|
|
|
|
|
<object> = copy(<object>) |
|
|
|
<object> = deepcopy(<object>) |
|
|
|
</code></pre></div> |
|
|
@ -1754,6 +1756,7 @@ CompletedProcess(args=[<span class="hljs-string">'bc'</span>, <span class="hljs- |
|
|
|
<li><strong>Module that performs conversions between a sequence of numbers and a bytes object.</strong></li> |
|
|
|
<li><strong>Machine’s native type sizes and byte order are used by default.</strong></li> |
|
|
|
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> struct <span class="hljs-keyword">import</span> pack, unpack, iter_unpack |
|
|
|
|
|
|
|
<bytes> = pack(<span class="hljs-string">'<format>'</span>, <num_1> [, <num_2>, ...]) |
|
|
|
<tuple> = unpack(<span class="hljs-string">'<format>'</span>, <bytes>) |
|
|
|
<tuples> = iter_unpack(<span class="hljs-string">'<format>'</span>, <bytes>) |
|
|
|