|
1306 | 1306 | <span class="hljs-keyword">raise</span>
|
1307 | 1307 | </code></pre></div>
|
1308 | 1308 |
|
1309 |
| -<div><h3 id="exceptionobject">Exception Object</h3><pre><code class="python language-python hljs">arguments = <name>.args |
1310 |
| -exc_type = <name>.__class__ |
1311 |
| -filename = <name>.__traceback__.tb_frame.f_code.co_filename |
1312 |
| -func_name = <name>.__traceback__.tb_frame.f_code.co_name |
1313 |
| -line = linecache.getline(filename, <name>.__traceback__.tb_lineno) |
1314 |
| -error_msg = traceback.format_exception(exc_type, <name>, <name>.__traceback__) |
| 1309 | +<div><h3 id="exceptionobject">Exception Object</h3><pre><code class="python language-python hljs">arguments = <name>.args |
| 1310 | +exc_type = <name>.__class__ |
| 1311 | +filename = <name>.__traceback__.tb_frame.f_code.co_filename |
| 1312 | +func_name = <name>.__traceback__.tb_frame.f_code.co_name |
| 1313 | +line = linecache.getline(filename, <name>.__traceback__.tb_lineno) |
| 1314 | +error_msg = traceback.format_exception(exc_type, <name>, <name>.__traceback__) |
1315 | 1315 | </code></pre></div>
|
1316 | 1316 |
|
1317 | 1317 | <div><h3 id="builtinexceptions">Built-in Exceptions</h3><pre><code class="text language-text">BaseException
|
|
1778 | 1778 | <div><h3 id="decode-2">Decode</h3><pre><code class="python language-python hljs"><bin_file>.write(<mview>) <span class="hljs-comment"># Writes mview to the binary file.</span>
|
1779 | 1779 | <bytes> = bytes(<mview>) <span class="hljs-comment"># Creates a new bytes object.</span>
|
1780 | 1780 | <bytes> = <bytes>.join(<coll_of_mviews>) <span class="hljs-comment"># Joins mviews using bytes object as sep.</span>
|
| 1781 | +<array> = array(<span class="hljs-string">'<typecode>'</span>, <mview>) <span class="hljs-comment"># Treats mview as a sequence of numbers.</span> |
1781 | 1782 | <list> = list(<mview>) <span class="hljs-comment"># Returns list of ints or floats.</span>
|
1782 | 1783 | <str> = str(<mview>, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Treats mview as a bytes object.</span>
|
1783 | 1784 | <int> = int.from_bytes(<mview>, byteorder=<span class="hljs-string">'big/little'</span>, signed=<span class="hljs-keyword">False</span>)
|
|
1963 | 1964 | <li><strong>Coroutine definition starts with <code class="python hljs"><span class="hljs-string">'async'</span></code> and its call with <code class="python hljs"><span class="hljs-string">'await'</span></code>.</strong></li>
|
1964 | 1965 | <li><strong><code class="python hljs"><span class="hljs-string">'asyncio.run(<coroutine>)'</span></code> is the main entry point for asynchronous programs.</strong></li>
|
1965 | 1966 | <li><strong>Functions wait(), gather() and as_completed() can be used when multiple coroutines need to be started at the same time.</strong></li>
|
1966 |
| -<li><strong>Asyncio module also provides it's own <a href="#queue">Queue</a>, <a href="#semaphoreeventbarrier">Event</a>, <a href="#lock">Lock</a> and <a href="#semaphoreeventbarrier">Semaphore</a> classes.</strong></li> |
| 1967 | +<li><strong>Asyncio module also provides its own <a href="#queue">Queue</a>, <a href="#semaphoreeventbarrier">Event</a>, <a href="#lock">Lock</a> and <a href="#semaphore-event-barrier">Semaphore</a> classes.</strong></li> |
1967 | 1968 | </ul><div><h4 id="runsaterminalgamewhereyoucontrolanasteriskthatmustavoidnumbers">Runs a terminal game where you control an asterisk that must avoid numbers:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> asyncio, collections, curses, enum, random
|
1968 | 1969 |
|
1969 | 1970 | P = collections.namedtuple(<span class="hljs-string">'P'</span>, <span class="hljs-string">'x y'</span>) <span class="hljs-comment"># Position</span>
|
|
0 commit comments