|
1761 | 1761 | <bytes> = bytes(<mview>) <span class="hljs-comment"># Creates a new bytes object.</span>
|
1762 | 1762 | <bytes> = <bytes>.join(<coll_of_mviews>) <span class="hljs-comment"># Joins mviews using bytes object as sep.</span>
|
1763 | 1763 | <list> = list(<mview>) <span class="hljs-comment"># Returns list of ints or floats.</span>
|
1764 |
| -<str> = str(<mview>, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Treats mview as a seqence of bytes.</span> |
| 1764 | +<str> = str(<mview>, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Treats mview as a bytes object.</span> |
1765 | 1765 | <int> = int.from_bytes(<mview>, byteorder=<span class="hljs-string">'big/little'</span>, signed=<span class="hljs-keyword">False</span>)
|
1766 | 1766 | <span class="hljs-string">'<hex>'</span> = <mview>.hex()
|
1767 | 1767 | </code></pre></div>
|
|
1772 | 1772 |
|
1773 | 1773 |
|
1774 | 1774 | <pre><code class="python language-python hljs"><deque>.appendleft(<el>) <span class="hljs-comment"># Opposite element is dropped if full.</span>
|
1775 |
| -<el> = <deque>.popleft() <span class="hljs-comment"># Raises IndexError if empty.</span> |
1776 | 1775 | <deque>.extendleft(<collection>) <span class="hljs-comment"># Collection gets reversed.</span>
|
| 1776 | +<el> = <deque>.popleft() <span class="hljs-comment"># Raises IndexError if empty.</span> |
1777 | 1777 | <deque>.rotate(n=<span class="hljs-number">1</span>) <span class="hljs-comment"># Rotates elements to the right.</span>
|
1778 | 1778 | </code></pre>
|
1779 | 1779 | <div><h2 id="threading"><a href="#threading" name="threading">#</a>Threading</h2><ul>
|
1780 | 1780 | <li><strong>CPython interpreter can only run a single thread at a time.</strong></li>
|
1781 |
| -<li><strong>That is why using multiple threads won't result in a faster execution, unless there is an I/O operation in the thread.</strong></li> |
| 1781 | +<li><strong>That is why using multiple threads won't result in a faster execution, unless one of the threads contains an I/O operation.</strong></li> |
1782 | 1782 | </ul><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> threading <span class="hljs-keyword">import</span> Thread, RLock
|
1783 | 1783 | </code></pre></div>
|
1784 | 1784 |
|
|
1824 | 1824 | <pre><code class="python language-python hljs"><Queue>.put(<el>) <span class="hljs-comment"># Blocks until queue stops being full.</span>
|
1825 | 1825 | <Queue>.put_nowait(<el>) <span class="hljs-comment"># Raises queue.Full exception if full.</span>
|
1826 | 1826 | <el> = <Queue>.get() <span class="hljs-comment"># Blocks until queue stops being empty.</span>
|
1827 |
| -<el> = <Queue>.get_nowait() <span class="hljs-comment"># Raises _queue.Empty exception if empty.</span> |
| 1827 | +<el> = <Queue>.get_nowait() <span class="hljs-comment"># Raises queue.Empty exception if empty.</span> |
1828 | 1828 | </code></pre>
|
1829 | 1829 | <div><h2 id="operator"><a href="#operator" name="operator">#</a>Operator</h2><p><strong>Module of functions that provide the functionality of operators.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> operator <span class="hljs-keyword">import</span> add, sub, mul, truediv, floordiv, mod, pow, neg, abs
|
1830 | 1830 | <span class="hljs-keyword">from</span> operator <span class="hljs-keyword">import</span> eq, ne, lt, le, gt, ge
|
|
1860 | 1860 | <sig> = signature(<function>)
|
1861 | 1861 | no_of_params = len(<sig>.parameters)
|
1862 | 1862 | param_names = list(<sig>.parameters.keys())
|
| 1863 | +param_kinds = [a.kind <span class="hljs-keyword">for</span> a <span class="hljs-keyword">in</span> <sig>.parameters.values()] |
1863 | 1864 | </code></pre></div>
|
1864 | 1865 |
|
1865 | 1866 | <div><h2 id="metaprograming"><a href="#metaprograming" name="metaprograming">#</a>Metaprograming</h2><p><strong>Code that generates code.</strong></p><div><h3 id="type-1">Type</h3><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"><code class="python language-python hljs"><class> = type(<span class="hljs-string">'<class_name>'</span>, <parents_tuple>, <attributes_dict>)</code></code></pre></div></div>
|
|
0 commit comments