Browse Source

Moved Threading in front of Coroutines

pull/192/head
Jure Šorn 5 months ago
parent
commit
3d9699ce33
7 changed files with 157 additions and 159 deletions
  1. 138
      README.md
  2. 110
      index.html
  3. 3
      parse.js
  4. 26
      pdf/index_for_pdf.html
  5. 26
      pdf/index_for_pdf_print.html
  6. 5
      pdf/remove_links.py
  7. 8
      web/script_2.js

138
README.md

@ -13,7 +13,7 @@ Contents
**   ** **3. Syntax:** **         ** **[`Args`](#arguments)**__,__ **[`Inline`](#inline)**__,__ **[`Import`](#imports)**__,__ **[`Decorator`](#decorator)**__,__ **[`Class`](#class)**__,__ **[`Duck_Types`](#duck-types)**__,__ **[`Enum`](#enum)**__,__ **[`Exception`](#exceptions)**__.__
**   ** **4. System:** **        ** **[`Exit`](#exit)**__,__ **[`Print`](#print)**__,__ **[`Input`](#input)**__,__ **[`Command_Line_Arguments`](#command-line-arguments)**__,__ **[`Open`](#open)**__,__ **[`Path`](#paths)**__,__ **[`OS_Commands`](#os-commands)**__.__
**   ** **5. Data:** **             ** **[`JSON`](#json)**__,__ **[`Pickle`](#pickle)**__,__ **[`CSV`](#csv)**__,__ **[`SQLite`](#sqlite)**__,__ **[`Bytes`](#bytes)**__,__ **[`Struct`](#struct)**__,__ **[`Array`](#array)**__,__ **[`Memory_View`](#memory-view)**__,__ **[`Deque`](#deque)**__.__
**   ** **6. Advanced:** **   ** **[`Threading`](#threading)**__,__ **[`Operator`](#operator)**__,__ **[`Match_Stmt`](#match-statement)**__,__ **[`Logging`](#logging)**__,__ **[`Introspection`](#introspection)**__,__ **[`Coroutines`](#coroutines)**__.__
**   ** **6. Advanced:** **   ** **[`Operator`](#operator)**__,__ **[`Match_Stmt`](#match-statement)**__,__ **[`Logging`](#logging)**__,__ **[`Introspection`](#introspection)**__,__ **[`Threading`](#threading)**__,__ **[`Coroutines`](#coroutines)**__.__
**   ** **7. Libraries:** **      ** **[`Progress_Bar`](#progress-bar)**__,__ **[`Plot`](#plot)**__,__ **[`Table`](#table)**__,__ **[`Console_App`](#console-app)**__,__ **[`GUI`](#gui-app)**__,__ **[`Scraping`](#scraping)**__,__ **[`Web`](#web-app)**__,__ **[`Profile`](#profiling)**__.__
**   ** **8. Multimedia:** **  ** **[`NumPy`](#numpy)**__,__ **[`Image`](#image)**__,__ **[`Animation`](#animation)**__,__ **[`Audio`](#audio)**__,__ **[`Synthesizer`](#synthesizer)**__,__ **[`Pygame`](#pygame)**__,__ **[`Pandas`](#pandas)**__,__ **[`Plotly`](#plotly)**__.__
@ -2086,7 +2086,7 @@ Memory View
Deque
-----
**A thread-safe list with efficient appends and pops from either side. Pronounced "deck".**
**List with efficient appends and pops from either side. Pronounced "deck".**
```python
from collections import deque
@ -2101,71 +2101,6 @@ from collections import deque
```
Threading
---------
**CPython interpreter can only run a single thread at a time. Using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.**
```python
from threading import Thread, Lock, RLock, Semaphore, Event, Barrier
from concurrent.futures import ThreadPoolExecutor, as_completed
```
### Thread
```python
<Thread> = Thread(target=<function>) # Use `args=<collection>` to set the arguments.
<Thread>.start() # Starts the thread. Also <Thread>.is_alive().
<Thread>.join() # Waits for the thread to finish.
```
* **Use `'kwargs=<dict>'` to pass keyword arguments to the function.**
* **Use `'daemon=True'`, or the program will not be able to exit while the thread is alive.**
### Lock
```python
<lock> = Lock/RLock() # RLock can only be released by acquirer.
<lock>.acquire() # Waits for the lock to be available.
<lock>.release() # Makes the lock available again.
```
#### Or:
```python
with <lock>: # Enters the block by calling acquire() and
... # exits it with release(), even on error.
```
### Semaphore, Event, Barrier
```python
<Semaphore> = Semaphore(value=1) # Lock that can be acquired by 'value' threads.
<Event> = Event() # Method wait() blocks until set() is called.
<Barrier> = Barrier(n_times) # Wait() blocks until it's called n_times.
```
### Queue
```python
<Queue> = queue.Queue(maxsize=0) # A thread-safe first-in-first-out queue.
<Queue>.put(<el>) # Blocks until queue stops being full.
<Queue>.put_nowait(<el>) # Raises queue.Full exception if full.
<el> = <Queue>.get() # Blocks until queue stops being empty.
<el> = <Queue>.get_nowait() # Raises queue.Empty exception if empty.
```
### Thread Pool Executor
```python
<Exec> = ThreadPoolExecutor(max_workers=None) # Or: `with ThreadPoolExecutor() as <name>: ...`
<iter> = <Exec>.map(<func>, <args_1>, ...) # Multithreaded and non-lazy map(). Keeps order.
<Futr> = <Exec>.submit(<func>, <arg_1>, ...) # Creates a thread and returns its Future obj.
<Exec>.shutdown() # Blocks until all threads finish executing.
```
```python
<bool> = <Future>.done() # Checks if the thread has finished executing.
<obj> = <Future>.result(timeout=None) # Waits for thread to finish and returns result.
<bool> = <Future>.cancel() # Cancels or returns False if running/finished.
<iter> = as_completed(<coll_of_Futures>) # `next(<iter>)` returns next completed Future.
```
* **Map() and as\_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called/blocking. Map() times from original call and as_completed() from first call to next(). As\_completed() fails if next() is called too late, even if all threads are done.**
* **Exceptions that happen inside threads are raised when map iterator's next() or Future's result() are called. Future's exception() method returns exception object or None.**
* **ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be [pickable](#pickle), queues must be sent using executor's 'initargs' and 'initializer' parameters, and executor should only be reachable via `'if __name__ == "__main__": ...'`.**
Operator
--------
**Module of functions that provide the functionality of operators. Functions are ordered and grouped by operator precedence from least to most binding. Logical and arithmetic operators in rows 1, 3 and 5 are also ordered by precedence within a group.**
@ -2316,6 +2251,71 @@ delattr(<obj>, '<name>') # Deletes attribute from __dict__. Also `del
```
Threading
---------
**CPython interpreter can only run a single thread at a time. Using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.**
```python
from threading import Thread, Lock, RLock, Semaphore, Event, Barrier
from concurrent.futures import ThreadPoolExecutor, as_completed
```
### Thread
```python
<Thread> = Thread(target=<function>) # Use `args=<collection>` to set the arguments.
<Thread>.start() # Starts the thread. Also <Thread>.is_alive().
<Thread>.join() # Waits for the thread to finish.
```
* **Use `'kwargs=<dict>'` to pass keyword arguments to the function.**
* **Use `'daemon=True'`, or the program will not be able to exit while the thread is alive.**
### Lock
```python
<lock> = Lock/RLock() # RLock can only be released by acquirer.
<lock>.acquire() # Waits for the lock to be available.
<lock>.release() # Makes the lock available again.
```
#### Or:
```python
with <lock>: # Enters the block by calling acquire() and
... # exits it with release(), even on error.
```
### Semaphore, Event, Barrier
```python
<Semaphore> = Semaphore(value=1) # Lock that can be acquired by 'value' threads.
<Event> = Event() # Method wait() blocks until set() is called.
<Barrier> = Barrier(n_times) # Wait() blocks until it's called n_times.
```
### Queue
```python
<Queue> = queue.Queue(maxsize=0) # A thread-safe first-in-first-out queue.
<Queue>.put(<el>) # Blocks until queue stops being full.
<Queue>.put_nowait(<el>) # Raises queue.Full exception if full.
<el> = <Queue>.get() # Blocks until queue stops being empty.
<el> = <Queue>.get_nowait() # Raises queue.Empty exception if empty.
```
### Thread Pool Executor
```python
<Exec> = ThreadPoolExecutor(max_workers=None) # Or: `with ThreadPoolExecutor() as <name>: ...`
<iter> = <Exec>.map(<func>, <args_1>, ...) # Multithreaded and non-lazy map(). Keeps order.
<Futr> = <Exec>.submit(<func>, <arg_1>, ...) # Creates a thread and returns its Future obj.
<Exec>.shutdown() # Blocks until all threads finish executing.
```
```python
<bool> = <Future>.done() # Checks if the thread has finished executing.
<obj> = <Future>.result(timeout=None) # Waits for thread to finish and returns result.
<bool> = <Future>.cancel() # Cancels or returns False if running/finished.
<iter> = as_completed(<coll_of_Futures>) # `next(<iter>)` returns next completed Future.
```
* **Map() and as\_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called/blocking. Map() times from original call and as_completed() from first call to next(). As\_completed() fails if next() is called too late, even if all threads are done.**
* **Exceptions that happen inside threads are raised when map iterator's next() or Future's result() are called. Future's exception() method returns exception object or None.**
* **ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be [pickable](#pickle), queues must be sent using executor's 'initargs' and 'initializer' parameters, and executor should only be reachable via `'if __name__ == "__main__": ...'`.**
Coroutines
----------
* **Coroutines have a lot in common with threads, but unlike threads, they only give up control when they call another coroutine and they don’t use as much memory.**
@ -2553,7 +2553,7 @@ import flask as fl
```python
app = fl.Flask(__name__) # Returns the app object. Put at the top.
app.run(host=None, port=None, debug=None) # Or: $ flask --app FILE run [--ARG[=VAL] …]
app.run(host=None, port=None, debug=None) # Or: $ flask --app FILE run [--ARG[=VAL]]…
```
* **Starts the app at `'http://localhost:5000'`. Use `'host="0.0.0.0"'` to run externally.**
* **Install a WSGI server like [Waitress](https://flask.palletsprojects.com/en/latest/deploying/waitress/) and a HTTP server such as [Nginx](https://flask.palletsprojects.com/en/latest/deploying/nginx/) for better security.**
@ -3146,7 +3146,7 @@ if __name__ == '__main__':
Pandas
------
**Data analysis library. For examples see [Plotly](#displays-a-line-chart-of-total-coronavirus-deaths-per-million-grouped-by-continent).**
**Data analysis library. For examples see [Plotly](#plotly).**
```python
# $ pip3 install pandas matplotlib

110
index.html

@ -86,7 +86,7 @@
<strong><span class="hljs-string"><span class="hljs-string">'3. Syntax'</span></span></strong>: [<a href="#arguments">Args</a>, <a href="#inline">Inline</a>, <a href="#imports">Import</a>, <a href="#decorator">Decorator</a>, <a href="#class">Class</a>, <a href="#ducktypes">Duck_Types</a>, <a href="#enum">Enum</a>, <a href="#exceptions">Exception</a>],
<strong><span class="hljs-string"><span class="hljs-string">'4. System'</span></span></strong>: [<a href="#exit">Exit</a>, <a href="#print">Print</a>, <a href="#input">Input</a>, <a href="#commandlinearguments">Command_Line_Arguments</a>, <a href="#open">Open</a>, <a href="#paths">Path</a>, <a href="#oscommands">OS_Commands</a>],
<strong><span class="hljs-string"><span class="hljs-string">'5. Data'</span></span></strong>: [<a href="#json">JSON</a>, <a href="#pickle">Pickle</a>, <a href="#csv">CSV</a>, <a href="#sqlite">SQLite</a>, <a href="#bytes">Bytes</a>, <a href="#struct">Struct</a>, <a href="#array">Array</a>, <a href="#memoryview">Memory_View</a>, <a href="#deque">Deque</a>],
<strong><span class="hljs-string"><span class="hljs-string">'6. Advanced'</span></span></strong>: [<a href="#threading">Threading</a>, <a href="#operator">Operator</a>, <a href="#matchstatement">Match_Stmt</a>, <a href="#logging">Logging</a>, <a href="#introspection">Introspection</a>, <a href="#coroutines">Coroutines</a>],
<strong><span class="hljs-string"><span class="hljs-string">'6. Advanced'</span></span></strong>: [<a href="#operator">Operator</a>, <a href="#matchstatement">Match_Stmt</a>, <a href="#logging">Logging</a>, <a href="#introspection">Introspection</a>, <a href="#threading">Threading</a>, <a href="#coroutines">Coroutines</a>],
<strong><span class="hljs-string"><span class="hljs-string">'7. Libraries'</span></span></strong>: [<a href="#progressbar">Progress_Bar</a>, <a href="#plot">Plot</a>, <a href="#table">Table</a>, <a href="#consoleapp">Console_App</a>, <a href="#guiapp">GUI</a>, <a href="#scraping">Scraping</a>, <a href="#webapp">Web</a>, <a href="#profiling">Profile</a>],
<strong><span class="hljs-string"><span class="hljs-string">'8. Multimedia'</span></span></strong>: [<a href="#numpy">NumPy</a>, <a href="#image">Image</a>, <a href="#animation">Animation</a>, <a href="#audio">Audio</a>, <a href="#synthesizer">Synthesizer</a>, <a href="#pygame">Pygame</a>, <a href="#pandas">Pandas</a>, <a href="#plotly">Plotly</a>]
}
@ -1714,7 +1714,7 @@ CompletedProcess(args=[<span class="hljs-string">'bc'</span>, <span class="hljs-
&lt;str&gt; = str(&lt;mview&gt;, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Treats memoryview as a bytes object.</span>
&lt;str&gt; = &lt;mview&gt;.hex() <span class="hljs-comment"># Returns hex pairs. Accepts `sep=&lt;str&gt;`.</span>
</code></pre>
<div><h2 id="deque"><a href="#deque" name="deque">#</a>Deque</h2><p><strong>A thread-safe list with efficient appends and pops from either side. Pronounced "deck".</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> deque
<div><h2 id="deque"><a href="#deque" name="deque">#</a>Deque</h2><p><strong>List with efficient appends and pops from either side. Pronounced "deck".</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> deque
</code></pre></div>
@ -1724,57 +1724,6 @@ CompletedProcess(args=[<span class="hljs-string">'bc'</span>, <span class="hljs-
&lt;deque&gt;.rotate(n=<span class="hljs-number">1</span>) <span class="hljs-comment"># Last element becomes first.</span>
&lt;el&gt; = &lt;deque&gt;.popleft() <span class="hljs-comment"># Raises IndexError if deque is empty.</span>
</code></pre>
<div><h2 id="threading"><a href="#threading" name="threading">#</a>Threading</h2><p><strong>CPython interpreter can only run a single thread at a time. Using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> threading <span class="hljs-keyword">import</span> Thread, Lock, RLock, Semaphore, Event, Barrier
<span class="hljs-keyword">from</span> concurrent.futures <span class="hljs-keyword">import</span> ThreadPoolExecutor, as_completed
</code></pre></div>
<div><h3 id="thread">Thread</h3><pre><code class="python language-python hljs">&lt;Thread&gt; = Thread(target=&lt;function&gt;) <span class="hljs-comment"># Use `args=&lt;collection&gt;` to set the arguments.</span>
&lt;Thread&gt;.start() <span class="hljs-comment"># Starts the thread. Also &lt;Thread&gt;.is_alive().</span>
&lt;Thread&gt;.join() <span class="hljs-comment"># Waits for the thread to finish.</span>
</code></pre></div>
<ul>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'kwargs=&lt;dict&gt;'</span></code> to pass keyword arguments to the function.</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'daemon=True'</span></code>, or the program will not be able to exit while the thread is alive.</strong></li>
</ul>
<div><h3 id="lock">Lock</h3><pre><code class="python language-python hljs">&lt;lock&gt; = Lock/RLock() <span class="hljs-comment"># RLock can only be released by acquirer.</span>
&lt;lock&gt;.acquire() <span class="hljs-comment"># Waits for the lock to be available.</span>
&lt;lock&gt;.release() <span class="hljs-comment"># Makes the lock available again.</span>
</code></pre></div>
<div><h4 id="or-1">Or:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">with</span> &lt;lock&gt;: <span class="hljs-comment"># Enters the block by calling acquire() and</span>
... <span class="hljs-comment"># exits it with release(), even on error.</span>
</code></pre></div>
<div><h3 id="semaphoreeventbarrier">Semaphore, Event, Barrier</h3><pre><code class="python language-python hljs">&lt;Semaphore&gt; = Semaphore(value=<span class="hljs-number">1</span>) <span class="hljs-comment"># Lock that can be acquired by 'value' threads.</span>
&lt;Event&gt; = Event() <span class="hljs-comment"># Method wait() blocks until set() is called.</span>
&lt;Barrier&gt; = Barrier(n_times) <span class="hljs-comment"># Wait() blocks until it's called n_times.</span>
</code></pre></div>
<div><h3 id="queue">Queue</h3><pre><code class="python language-python hljs">&lt;Queue&gt; = queue.Queue(maxsize=<span class="hljs-number">0</span>) <span class="hljs-comment"># A thread-safe first-in-first-out queue.</span>
&lt;Queue&gt;.put(&lt;el&gt;) <span class="hljs-comment"># Blocks until queue stops being full.</span>
&lt;Queue&gt;.put_nowait(&lt;el&gt;) <span class="hljs-comment"># Raises queue.Full exception if full.</span>
&lt;el&gt; = &lt;Queue&gt;.get() <span class="hljs-comment"># Blocks until queue stops being empty.</span>
&lt;el&gt; = &lt;Queue&gt;.get_nowait() <span class="hljs-comment"># Raises queue.Empty exception if empty.</span>
</code></pre></div>
<div><h3 id="threadpoolexecutor">Thread Pool Executor</h3><pre><code class="python language-python hljs">&lt;Exec&gt; = ThreadPoolExecutor(max_workers=<span class="hljs-keyword">None</span>) <span class="hljs-comment"># Or: `with ThreadPoolExecutor() as &lt;name&gt;: ...`</span>
&lt;iter&gt; = &lt;Exec&gt;.map(&lt;func&gt;, &lt;args_1&gt;, ...) <span class="hljs-comment"># Multithreaded and non-lazy map(). Keeps order.</span>
&lt;Futr&gt; = &lt;Exec&gt;.submit(&lt;func&gt;, &lt;arg_1&gt;, ...) <span class="hljs-comment"># Creates a thread and returns its Future obj.</span>
&lt;Exec&gt;.shutdown() <span class="hljs-comment"># Blocks until all threads finish executing.</span>
</code></pre></div>
<pre><code class="python language-python hljs">&lt;bool&gt; = &lt;Future&gt;.done() <span class="hljs-comment"># Checks if the thread has finished executing.</span>
&lt;obj&gt; = &lt;Future&gt;.result(timeout=<span class="hljs-keyword">None</span>) <span class="hljs-comment"># Waits for thread to finish and returns result.</span>
&lt;bool&gt; = &lt;Future&gt;.cancel() <span class="hljs-comment"># Cancels or returns False if running/finished.</span>
&lt;iter&gt; = as_completed(&lt;coll_of_Futures&gt;) <span class="hljs-comment"># `next(&lt;iter&gt;)` returns next completed Future.</span>
</code></pre>
<ul>
<li><strong>Map() and as_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called/blocking. Map() times from original call and as_completed() from first call to next(). As_completed() fails if next() is called too late, even if all threads are done.</strong></li>
<li><strong>Exceptions that happen inside threads are raised when map iterator's next() or Future's result() are called. Future's exception() method returns exception object or None.</strong></li>
<li><strong>ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be <a href="#pickle">pickable</a>, queues must be sent using executor's 'initargs' and 'initializer' parameters, and executor should only be reachable via <code class="python hljs"><span class="hljs-string">'if __name__ == "__main__": ...'</span></code>.</strong></li>
</ul>
<div><h2 id="operator"><a href="#operator" name="operator">#</a>Operator</h2><p><strong>Module of functions that provide the functionality of operators. Functions are ordered and grouped by operator precedence from least to most binding. Logical and arithmetic operators in rows 1, 3 and 5 are also ordered by precedence within a group.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> operator <span class="hljs-keyword">as</span> op
</code></pre></div>
@ -1894,6 +1843,57 @@ delattr(&lt;obj&gt;, <span class="hljs-string">'&lt;name&gt;'</span>)
&lt;memb&gt; = &lt;Param&gt;.kind <span class="hljs-comment"># Returns ParameterKind member (Parameter.KEYWORD_ONLY, …).</span>
&lt;type&gt; = &lt;Param&gt;.annotation <span class="hljs-comment"># Returns Parameter.empty if missing. Also &lt;Param&gt;.default.</span>
</code></pre>
<div><h2 id="threading"><a href="#threading" name="threading">#</a>Threading</h2><p><strong>CPython interpreter can only run a single thread at a time. Using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> threading <span class="hljs-keyword">import</span> Thread, Lock, RLock, Semaphore, Event, Barrier
<span class="hljs-keyword">from</span> concurrent.futures <span class="hljs-keyword">import</span> ThreadPoolExecutor, as_completed
</code></pre></div>
<div><h3 id="thread">Thread</h3><pre><code class="python language-python hljs">&lt;Thread&gt; = Thread(target=&lt;function&gt;) <span class="hljs-comment"># Use `args=&lt;collection&gt;` to set the arguments.</span>
&lt;Thread&gt;.start() <span class="hljs-comment"># Starts the thread. Also &lt;Thread&gt;.is_alive().</span>
&lt;Thread&gt;.join() <span class="hljs-comment"># Waits for the thread to finish.</span>
</code></pre></div>
<ul>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'kwargs=&lt;dict&gt;'</span></code> to pass keyword arguments to the function.</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'daemon=True'</span></code>, or the program will not be able to exit while the thread is alive.</strong></li>
</ul>
<div><h3 id="lock">Lock</h3><pre><code class="python language-python hljs">&lt;lock&gt; = Lock/RLock() <span class="hljs-comment"># RLock can only be released by acquirer.</span>
&lt;lock&gt;.acquire() <span class="hljs-comment"># Waits for the lock to be available.</span>
&lt;lock&gt;.release() <span class="hljs-comment"># Makes the lock available again.</span>
</code></pre></div>
<div><h4 id="or-1">Or:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">with</span> &lt;lock&gt;: <span class="hljs-comment"># Enters the block by calling acquire() and</span>
... <span class="hljs-comment"># exits it with release(), even on error.</span>
</code></pre></div>
<div><h3 id="semaphoreeventbarrier">Semaphore, Event, Barrier</h3><pre><code class="python language-python hljs">&lt;Semaphore&gt; = Semaphore(value=<span class="hljs-number">1</span>) <span class="hljs-comment"># Lock that can be acquired by 'value' threads.</span>
&lt;Event&gt; = Event() <span class="hljs-comment"># Method wait() blocks until set() is called.</span>
&lt;Barrier&gt; = Barrier(n_times) <span class="hljs-comment"># Wait() blocks until it's called n_times.</span>
</code></pre></div>
<div><h3 id="queue">Queue</h3><pre><code class="python language-python hljs">&lt;Queue&gt; = queue.Queue(maxsize=<span class="hljs-number">0</span>) <span class="hljs-comment"># A thread-safe first-in-first-out queue.</span>
&lt;Queue&gt;.put(&lt;el&gt;) <span class="hljs-comment"># Blocks until queue stops being full.</span>
&lt;Queue&gt;.put_nowait(&lt;el&gt;) <span class="hljs-comment"># Raises queue.Full exception if full.</span>
&lt;el&gt; = &lt;Queue&gt;.get() <span class="hljs-comment"># Blocks until queue stops being empty.</span>
&lt;el&gt; = &lt;Queue&gt;.get_nowait() <span class="hljs-comment"># Raises queue.Empty exception if empty.</span>
</code></pre></div>
<div><h3 id="threadpoolexecutor">Thread Pool Executor</h3><pre><code class="python language-python hljs">&lt;Exec&gt; = ThreadPoolExecutor(max_workers=<span class="hljs-keyword">None</span>) <span class="hljs-comment"># Or: `with ThreadPoolExecutor() as &lt;name&gt;: ...`</span>
&lt;iter&gt; = &lt;Exec&gt;.map(&lt;func&gt;, &lt;args_1&gt;, ...) <span class="hljs-comment"># Multithreaded and non-lazy map(). Keeps order.</span>
&lt;Futr&gt; = &lt;Exec&gt;.submit(&lt;func&gt;, &lt;arg_1&gt;, ...) <span class="hljs-comment"># Creates a thread and returns its Future obj.</span>
&lt;Exec&gt;.shutdown() <span class="hljs-comment"># Blocks until all threads finish executing.</span>
</code></pre></div>
<pre><code class="python language-python hljs">&lt;bool&gt; = &lt;Future&gt;.done() <span class="hljs-comment"># Checks if the thread has finished executing.</span>
&lt;obj&gt; = &lt;Future&gt;.result(timeout=<span class="hljs-keyword">None</span>) <span class="hljs-comment"># Waits for thread to finish and returns result.</span>
&lt;bool&gt; = &lt;Future&gt;.cancel() <span class="hljs-comment"># Cancels or returns False if running/finished.</span>
&lt;iter&gt; = as_completed(&lt;coll_of_Futures&gt;) <span class="hljs-comment"># `next(&lt;iter&gt;)` returns next completed Future.</span>
</code></pre>
<ul>
<li><strong>Map() and as_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called/blocking. Map() times from original call and as_completed() from first call to next(). As_completed() fails if next() is called too late, even if all threads are done.</strong></li>
<li><strong>Exceptions that happen inside threads are raised when map iterator's next() or Future's result() are called. Future's exception() method returns exception object or None.</strong></li>
<li><strong>ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be <a href="#pickle">pickable</a>, queues must be sent using executor's 'initargs' and 'initializer' parameters, and executor should only be reachable via <code class="python hljs"><span class="hljs-string">'if __name__ == "__main__": ...'</span></code>.</strong></li>
</ul>
<div><h2 id="coroutines"><a href="#coroutines" name="coroutines">#</a>Coroutines</h2><ul>
<li><strong>Coroutines have a lot in common with threads, but unlike threads, they only give up control when they call another coroutine and they don’t use as much memory.</strong></li>
<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>
@ -2087,7 +2087,7 @@ print(<span class="hljs-string">f'<span class="hljs-subst">{python_url}</span>,
<pre><code class="python language-python hljs">app = fl.Flask(__name__) <span class="hljs-comment"># Returns the app object. Put at the top.</span>
app.run(host=<span class="hljs-keyword">None</span>, port=<span class="hljs-keyword">None</span>, debug=<span class="hljs-keyword">None</span>) <span class="hljs-comment"># Or: $ flask --app FILE run [--ARG[=VAL] …]</span>
app.run(host=<span class="hljs-keyword">None</span>, port=<span class="hljs-keyword">None</span>, debug=<span class="hljs-keyword">None</span>) <span class="hljs-comment"># Or: $ flask --app FILE run [--ARG[=VAL]]…</span>
</code></pre>
<ul>
<li><strong>Starts the app at <code class="python hljs"><span class="hljs-string">'http://localhost:5000'</span></code>. Use <code class="python hljs"><span class="hljs-string">'host="0.0.0.0"'</span></code> to run externally.</strong></li>
@ -2568,7 +2568,7 @@ W, H, MAX_S = <span class="hljs-number">50</span>, <span class="hljs-number">50<
main()
</code></pre></div>
<div><h2 id="pandas"><a href="#pandas" name="pandas">#</a>Pandas</h2><p><strong>Data analysis library. For examples see <a href="#displaysalinechartoftotalcoronavirusdeathspermilliongroupedbycontinent">Plotly</a>.</strong></p><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install pandas matplotlib</span>
<div><h2 id="pandas"><a href="#pandas" name="pandas">#</a>Pandas</h2><p><strong>Data analysis library. For examples see <a href="#plotly">Plotly</a>.</strong></p><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install pandas matplotlib</span>
<span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd, matplotlib.pyplot <span class="hljs-keyword">as</span> plt
</code></pre></div>

3
parse.js

@ -36,7 +36,7 @@ const TOC =
' <strong><span class="hljs-string">\'3. Syntax\'</span></strong>: [<a href="#arguments">Args</a>, <a href="#inline">Inline</a>, <a href="#imports">Import</a>, <a href="#decorator">Decorator</a>, <a href="#class">Class</a>, <a href="#ducktypes">Duck_Types</a>, <a href="#enum">Enum</a>, <a href="#exceptions">Exception</a>],\n' +
' <strong><span class="hljs-string">\'4. System\'</span></strong>: [<a href="#exit">Exit</a>, <a href="#print">Print</a>, <a href="#input">Input</a>, <a href="#commandlinearguments">Command_Line_Arguments</a>, <a href="#open">Open</a>, <a href="#paths">Path</a>, <a href="#oscommands">OS_Commands</a>],\n' +
' <strong><span class="hljs-string">\'5. Data\'</span></strong>: [<a href="#json">JSON</a>, <a href="#pickle">Pickle</a>, <a href="#csv">CSV</a>, <a href="#sqlite">SQLite</a>, <a href="#bytes">Bytes</a>, <a href="#struct">Struct</a>, <a href="#array">Array</a>, <a href="#memoryview">Memory_View</a>, <a href="#deque">Deque</a>],\n' +
' <strong><span class="hljs-string">\'6. Advanced\'</span></strong>: [<a href="#threading">Threading</a>, <a href="#operator">Operator</a>, <a href="#matchstatement">Match_Stmt</a>, <a href="#logging">Logging</a>, <a href="#introspection">Introspection</a>, <a href="#coroutines">Coroutines</a>],\n' +
' <strong><span class="hljs-string">\'6. Advanced\'</span></strong>: [<a href="#operator">Operator</a>, <a href="#matchstatement">Match_Stmt</a>, <a href="#logging">Logging</a>, <a href="#introspection">Introspection</a>, <a href="#threading">Threading</a>, <a href="#coroutines">Coroutines</a>],\n' +
' <strong><span class="hljs-string">\'7. Libraries\'</span></strong>: [<a href="#progressbar">Progress_Bar</a>, <a href="#plot">Plot</a>, <a href="#table">Table</a>, <a href="#consoleapp">Console_App</a>, <a href="#guiapp">GUI</a>, <a href="#scraping">Scraping</a>, <a href="#webapp">Web</a>, <a href="#profiling">Profile</a>],\n' +
' <strong><span class="hljs-string">\'8. Multimedia\'</span></strong>: [<a href="#numpy">NumPy</a>, <a href="#image">Image</a>, <a href="#animation">Animation</a>, <a href="#audio">Audio</a>, <a href="#synthesizer">Synthesizer</a>, <a href="#pygame">Pygame</a>, <a href="#pandas">Pandas</a>, <a href="#plotly">Plotly</a>]\n' +
'}\n' +
@ -711,7 +711,6 @@ function getMd() {
var readme = readme.replace("#semaphore-event-barrier", "#semaphoreeventbarrier");
var readme = readme.replace("#semaphore-event-barrier", "#semaphoreeventbarrier");
var readme = readme.replace("#dataframe-plot-encode-decode", "#dataframeplotencodedecode");
var readme = readme.replace("#displays-a-line-chart-of-total-coronavirus-deaths-per-million-grouped-by-continent", "#displaysalinechartoftotalcoronavirusdeathspermilliongroupedbycontinent");
const converter = new showdown.Converter();
return converter.makeHtml(readme);
}

26
pdf/index_for_pdf.html

@ -14,7 +14,7 @@
<h3 id="b">B</h3>
<p><strong>beautifulsoup library, <a href="#scrapespythonsurlandlogofromitswikipediapage">35</a></strong><br>
<strong>binary representation, <a href="#ints">7</a>, <a href="#binhex">8</a></strong><br>
<strong>bitwise operators, <a href="#bitwiseoperators">8</a>, <a href="#operator">31</a></strong><br>
<strong>bitwise operators, <a href="#bitwiseoperators">8</a>, <a href="#operator">30</a></strong><br>
<strong>bytes, <a href="#open">22</a>-<a href="#modes">23</a>, <a href="#pickle">25</a>, <a href="#bytes">28</a>-<a href="#memoryview">29</a></strong> </p>
<h3 id="c">C</h3>
<p><strong>cache, <a href="#cache">13</a></strong><br>
@ -26,7 +26,7 @@
<strong>combinatorics, <a href="#combinatorics">8</a></strong><br>
<strong>command line arguments, <a href="#commandlinearguments">22</a></strong><br>
<strong>comprehensions, <a href="#comprehensions">11</a></strong><br>
<strong>context manager, <a href="#contextmanager">17</a>, <a href="#readtextfromfile">23</a>, <a href="#or">27</a>, <a href="#or-1">30</a></strong><br>
<strong>context manager, <a href="#contextmanager">17</a>, <a href="#readtextfromfile">23</a>, <a href="#or">27</a>, <a href="#or-1">32</a></strong><br>
<strong>copy function, <a href="#copy">15</a></strong><br>
<strong>coroutine, <a href="#coroutines">33</a></strong><br>
<strong>counter, <a href="#counter">2</a>, <a href="#generator">4</a>, <a href="#nonlocal">12</a>, <a href="#iterator-1">17</a></strong><br>
@ -44,7 +44,7 @@
<p><strong>enum module, <a href="#enum">19</a>-<a href="#inline-1">20</a></strong><br>
<strong>enumerate function, <a href="#enumerate">3</a></strong><br>
<strong>excel, <a href="#dataframeencodedecode">46</a></strong><br>
<strong>exceptions, <a href="#exceptions">20</a>-<a href="#exceptionobject">21</a>, <a href="#exceptions-1">23</a>, <a href="#logging">32</a></strong><br>
<strong>exceptions, <a href="#exceptions">20</a>-<a href="#exceptionobject">21</a>, <a href="#exceptions-1">23</a>, <a href="#logging">31</a></strong><br>
<strong>exit function, <a href="#exit">21</a></strong> </p>
<h3 id="f">F</h3>
<p><strong>files, <a href="#print">22</a>-<a href="#memoryview">29</a>, <a href="#runsabasicfileexplorerintheconsole">34</a>, <a href="#dataframeencodedecode">46</a></strong><br>
@ -66,9 +66,9 @@
<strong>imports, <a href="#imports">12</a></strong><br>
<strong>inline, <a href="#otheruses">11</a>, <a href="#dataclass">15</a>, <a href="#inline-1">20</a></strong><br>
<strong>input function, <a href="#input">22</a></strong><br>
<strong>introspection, <a href="#exceptionobject">21</a>, <a href="#introspection">32</a></strong><br>
<strong>introspection, <a href="#exceptionobject">21</a>, <a href="#introspection">31</a></strong><br>
<strong>ints, <a href="#abstractbaseclasses">4</a>, <a href="#ints">7</a>, <a href="#random">8</a>, <a href="#encode-1">28</a></strong><br>
<strong>is operator, <a href="#comparable">16</a>, <a href="#operator">31</a></strong><br>
<strong>is operator, <a href="#comparable">16</a>, <a href="#operator">30</a></strong><br>
<strong>iterable, <a href="#abstractbaseclasses">4</a>, <a href="#iterable">18</a>, <a href="#tableofrequiredandautomaticallyavailablespecialmethods">19</a></strong><br>
<strong>iterator, <a href="#enumerate">3</a>-<a href="#generator">4</a>, <a href="#comprehensions">11</a>, <a href="#iterator-1">17</a></strong><br>
<strong>itertools module, <a href="#itertools">3</a>, <a href="#combinatorics">8</a></strong> </p>
@ -78,12 +78,12 @@
<p><strong>lambda, <a href="#lambda">11</a></strong><br>
<strong>lists, <a href="#list">1</a>-<a href="#list">2</a>, <a href="#abstractbaseclasses">4</a>, <a href="#otheruses">11</a>, <a href="#sequence">18</a>-<a href="#tableofrequiredandautomaticallyavailablespecialmethods">19</a>, <a href="#collectionsandtheirexceptions">21</a></strong><br>
<strong>locale module, <a href="#sortable">16</a></strong><br>
<strong>logging, <a href="#logging">32</a></strong> </p>
<strong>logging, <a href="#logging">31</a></strong> </p>
<h3 id="m">M</h3>
<p><strong>main function, <a href="#main">1</a>, <a href="#basicscripttemplate">49</a></strong><br>
<strong>match statement, <a href="#matchstatement">31</a></strong><br>
<strong>match statement, <a href="#matchstatement">30</a></strong><br>
<strong>matplotlib library, <a href="#plot">34</a>, <a href="#series">44</a>, <a href="#dataframeencodedecode">46</a></strong><br>
<strong>map function, <a href="#mapfilterreduce">11</a>, <a href="#operator">31</a></strong><br>
<strong>map function, <a href="#mapfilterreduce">11</a>, <a href="#operator">30</a></strong><br>
<strong>math module, <a href="#numbers">7</a></strong><br>
<strong>memoryviews, <a href="#memoryview">29</a></strong><br>
<strong>module, <a href="#imports">12</a></strong> </p>
@ -94,7 +94,7 @@
<strong>numpy library, <a href="#numpy">37</a>-<a href="#indexing">38</a></strong> </p>
<h3 id="o">O</h3>
<p><strong>open function, <a href="#contextmanager">17</a>, <a href="#open">22</a>-<a href="#modes">23</a>, <a href="#readobjectfromjsonfile">25</a>, <a href="#readrowsfromcsvfile">26</a>, <a href="#readbytesfromfile">28</a></strong><br>
<strong>operator module, <a href="#operator">31</a></strong><br>
<strong>operator module, <a href="#operator">30</a></strong><br>
<strong>os commands, <a href="#paths">23</a>-<a href="#shellcommands">25</a>, <a href="#runsabasicfileexplorerintheconsole">34</a></strong> </p>
<h3 id="p">P</h3>
<p><strong>pandas library, <a href="#pandas">44</a>-<a href="#displaysamultiaxislinechartoftotalcoronaviruscasesandchangesinpricesofbitcoindowjonesandgold">48</a></strong><br>
@ -109,12 +109,12 @@
<strong>property decorator, <a href="#property">15</a></strong><br>
<strong>pygame library, <a href="#pygame">42</a>-<a href="#basicmariobrothersexample">43</a></strong> </p>
<h3 id="q">Q</h3>
<p><strong>queues, <a href="#deque">29</a>, <a href="#queue">30</a>, <a href="#runsaterminalgamewhereyoucontrolanasteriskthatmustavoidnumbers">33</a></strong> </p>
<p><strong>queues, <a href="#deque">29</a>, <a href="#queue">32</a>, <a href="#runsaterminalgamewhereyoucontrolanasteriskthatmustavoidnumbers">33</a></strong> </p>
<h3 id="r">R</h3>
<p><strong>random module, <a href="#random">8</a></strong><br>
<strong>ranges, <a href="#range">3</a>, <a href="#abstractbaseclasses">4</a></strong><br>
<strong>recursion, <a href="#cache">13</a>, <a href="#builtinexceptions">21</a></strong><br>
<strong>reduce function, <a href="#mapfilterreduce">11</a>, <a href="#operator">31</a></strong><br>
<strong>reduce function, <a href="#mapfilterreduce">11</a></strong><br>
<strong>regular expressions, <a href="#regex">5</a>-<a href="#specialsequences">6</a></strong><br>
<strong>requests library, <a href="#scrapespythonsurlandlogofromitswikipediapage">35</a>, <a href="#startstheappinitsownthreadandqueriesitsrestapi">36</a></strong> </p>
<h3 id="s">S</h3>
@ -136,11 +136,11 @@
<h3 id="t">T</h3>
<p><strong>table, <a href="#csv">26</a>, <a href="#example-1">27</a>, <a href="#table">34</a>, <a href="#numpy">37</a>-<a href="#indexing">38</a>, <a href="#dataframe">45</a>-<a href="#dataframeaggregatetransformmap">46</a></strong><br>
<strong>template, <a href="#format">6</a>, <a href="#dynamicrequest">36</a></strong><br>
<strong>threading module, <a href="#threading">30</a>, <a href="#startstheappinitsownthreadandqueriesitsrestapi">36</a></strong><br>
<strong>threading module, <a href="#threading">32</a>, <a href="#startstheappinitsownthreadandqueriesitsrestapi">36</a></strong><br>
<strong>time module, <a href="#progressbar">34</a>, <a href="#profiling">36</a></strong><br>
<strong>tuples, <a href="#tuple">3</a>, <a href="#abstractbaseclasses">4</a>, <a href="#otheruses">11</a>, <a href="#sequence">18</a>-<a href="#tableofrequiredandautomaticallyavailablespecialmethods">19</a></strong><br>
<strong>type, <a href="#type">4</a></strong><br>
<strong>type annotations, <a href="#typeannotations">15</a>, <a href="#introspection">32</a></strong> </p>
<strong>type annotations, <a href="#typeannotations">15</a>, <a href="#introspection">31</a></strong> </p>
<h3 id="w">W</h3>
<p><strong>wave module, <a href="#audio">40</a>-<a href="#writefloatsamplestowavfile">41</a></strong><br>
<strong>web, <a href="#webapp">36</a></strong> </p>

26
pdf/index_for_pdf_print.html

@ -14,7 +14,7 @@
<h3 id="b">B</h3>
<p><strong>beautifulsoup library, 35</strong><br>
<strong>binary representation, 7, 8</strong><br>
<strong>bitwise operators, 8, 31</strong><br>
<strong>bitwise operators, 8, 30</strong><br>
<strong>bytes, 22-23, 25, 28-29</strong> </p>
<h3 id="c">C</h3>
<p><strong>cache, 13</strong><br>
@ -26,7 +26,7 @@
<strong>combinatorics, 8</strong><br>
<strong>command line arguments, 22</strong><br>
<strong>comprehensions, 11</strong><br>
<strong>context manager, 17, 23, 27, 30</strong><br>
<strong>context manager, 17, 23, 27, 32</strong><br>
<strong>copy function, 15</strong><br>
<strong>coroutine, 33</strong><br>
<strong>counter, 2, 4, 12, 17</strong><br>
@ -44,7 +44,7 @@
<p><strong>enum module, 19-20</strong><br>
<strong>enumerate function, 3</strong><br>
<strong>excel, 46</strong><br>
<strong>exceptions, 20-21, 23, 32</strong><br>
<strong>exceptions, 20-21, 23, 31</strong><br>
<strong>exit function, 21</strong> </p>
<h3 id="f">F</h3>
<p><strong>files, 22-29, 34, 46</strong><br>
@ -66,9 +66,9 @@
<strong>imports, 12</strong><br>
<strong>inline, 11, 15, 20</strong><br>
<strong>input function, 22</strong><br>
<strong>introspection, 21, 32</strong><br>
<strong>introspection, 21, 31</strong><br>
<strong>ints, 4, 7, 8, 28</strong><br>
<strong>is operator, 16, 31</strong><br>
<strong>is operator, 16, 30</strong><br>
<strong>iterable, 4, 18, 19</strong><br>
<strong>iterator, 3-4, 11, 17</strong><br>
<strong>itertools module, 3, 8</strong> </p>
@ -78,12 +78,12 @@
<p><strong>lambda, 11</strong><br>
<strong>lists, 1-2, 4, 11, 18-19, 21</strong><br>
<strong>locale module, 16</strong><br>
<strong>logging, 32</strong> </p>
<strong>logging, 31</strong> </p>
<h3 id="m">M</h3>
<p><strong>main function, 1, 49</strong><br>
<strong>match statement, 31</strong><br>
<strong>match statement, 30</strong><br>
<strong>matplotlib library, 34, 44, 46</strong><br>
<strong>map function, 11, 31</strong><br>
<strong>map function, 11, 30</strong><br>
<strong>math module, 7</strong><br>
<strong>memoryviews, 29</strong><br>
<strong>module, 12</strong> </p>
@ -94,7 +94,7 @@
<strong>numpy library, 37-38</strong> </p>
<h3 id="o">O</h3>
<p><strong>open function, 17, 22-23, 25, 26, 28</strong><br>
<strong>operator module, 31</strong><br>
<strong>operator module, 30</strong><br>
<strong>os commands, 23-25, 34</strong> </p>
<h3 id="p">P</h3>
<p><strong>pandas library, 44-48</strong><br>
@ -109,12 +109,12 @@
<strong>property decorator, 15</strong><br>
<strong>pygame library, 42-43</strong> </p>
<h3 id="q">Q</h3>
<p><strong>queues, 29, 30, 33</strong> </p>
<p><strong>queues, 29, 32, 33</strong> </p>
<h3 id="r">R</h3>
<p><strong>random module, 8</strong><br>
<strong>ranges, 3, 4</strong><br>
<strong>recursion, 13, 21</strong><br>
<strong>reduce function, 11, 31</strong><br>
<strong>reduce function, 11</strong><br>
<strong>regular expressions, 5-6</strong><br>
<strong>requests library, 35, 36</strong> </p>
<h3 id="s">S</h3>
@ -136,11 +136,11 @@
<h3 id="t">T</h3>
<p><strong>table, 26, 27, 34, 37-38, 45-46</strong><br>
<strong>template, 6, 36</strong><br>
<strong>threading module, 30, 36</strong><br>
<strong>threading module, 32, 36</strong><br>
<strong>time module, 34, 36</strong><br>
<strong>tuples, 3, 4, 11, 18-19</strong><br>
<strong>type, 4</strong><br>
<strong>type annotations, 15, 32</strong> </p>
<strong>type annotations, 15, 31</strong> </p>
<h3 id="w">W</h3>
<p><strong>wave module, 40-41</strong><br>
<strong>web, 36</strong> </p>

5
pdf/remove_links.py

@ -20,15 +20,14 @@ MATCHES = {
'<strong>Objects returned by the <a href="#itertools">itertools</a> module, such as count, repeat and cycle.</strong>': '<strong>Objects returned by the itertools module, such as count, repeat and cycle (p. 3).</strong>',
'<strong>Generators returned by the <a href="#generator">generator functions</a> and <a href="#comprehensions">generator expressions</a>.</strong>': '<strong>Generators returned by the generator functions (p. 4) and generator expressions (p. 11).</strong>',
'<strong>File objects returned by the <a href="#open">open()</a> function, etc.</strong>': '<strong>File objects returned by the open() function (p. 22), etc.</strong>',
'<strong>Use <code class="python hljs"><span class="hljs-string">\'logging.exception(&lt;str&gt;)\'</span></code> to log the passed message, followed by the full error message of the caught exception. For details see <a href="#logging">logging</a>.</strong>': '<strong>Use <code class="python hljs"><span class="hljs-string">\'logging.exception(&lt;str&gt;)\'</span></code> to log the passed message, followed by the full error message of the caught exception. For details see logging (p. 32).</strong>',
'<strong>Use <code class="python hljs"><span class="hljs-string">\'logging.exception(&lt;str&gt;)\'</span></code> to log the passed message, followed by the full error message of the caught exception. For details see <a href="#logging">logging</a>.</strong>': '<strong>Use <code class="python hljs"><span class="hljs-string">\'logging.exception(&lt;str&gt;)\'</span></code> to log the passed message, followed by the full error message of the caught exception. For details see logging (p. 31).</strong>',
'<strong>Functions report OS related errors by raising either OSError or one of its <a href="#exceptions-1">subclasses</a>.</strong>': '<strong>Functions report OS related errors by raising OSError or one of its subclasses (p. 23).</strong>',
'<strong>To print the spreadsheet to the console use <a href="#table">Tabulate</a> library.</strong>': '<strong>To print the spreadsheet to the console use Tabulate library (p. 34).</strong>',
'<strong>For XML and binary Excel files (xlsx, xlsm and xlsb) use <a href="#dataframeplotencodedecode">Pandas</a> library.</strong>': '<strong>For XML and binary Excel files (xlsx, xlsm and xlsb) use Pandas library (p. 46).</strong>',
'<strong>Bools will be stored and returned as ints and dates as <a href="#encode">ISO formatted strings</a>.</strong>': '<strong>Bools will be stored and returned as ints and dates as ISO formatted strings (p. 9).</strong>',
'<strong>ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be <a href="#pickle">pickable</a>, queues must be sent using executor\'s \'initargs\' and \'initializer\' parameters, and executor should only be reachable via <code class="python hljs"><span class="hljs-string">\'if __name__ == "__main__": ...\'</span></code>.</strong>': '<strong>ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be pickable, queues must be sent using executor\'s \'initargs\' and \'initializer\' parameters, and executor should only be reachable via <code class="python hljs"><span class="hljs-string">\'if __name__ == "__main__": ...\'</span></code>.</strong>',
'<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="#semaphoreeventbarrier">Semaphore</a> classes.</strong>': '<strong>Asyncio module also provides its own Queue, Event, Lock and Semaphore classes (p. 30).</strong>',
'<strong>Install a WSGI server like <a href="https://flask.palletsprojects.com/en/latest/deploying/waitress/">Waitress</a> and a HTTP server such as <a href="https://flask.palletsprojects.com/en/latest/deploying/nginx/">Nginx</a> for better security.</strong>': '<strong>Install a WSGI server like Waitress and a HTTP server such as Nginx for better security.</strong>',
'<strong>Data analysis library. For examples see <a href="#displays-a-line-chart-of-total-coronavirus-deaths-per-million-grouped-by-continent">Plotly</a>.</strong>': '<strong>Data analysis library. For examples see Plotly (p. 47).</strong>',
'<strong>Data analysis library. For examples see <a href="#plotly">Plotly</a>.</strong>': '<strong>Data analysis library. For examples see Plotly (p. 47).</strong>',
}

8
web/script_2.js

@ -5,7 +5,7 @@ const TOC =
' <strong><span class="hljs-string">\'3. Syntax\'</span></strong>: [<a href="#arguments">Args</a>, <a href="#inline">Inline</a>, <a href="#imports">Import</a>, <a href="#decorator">Decorator</a>, <a href="#class">Class</a>, <a href="#ducktypes">Duck_Types</a>, <a href="#enum">Enum</a>, <a href="#exceptions">Exception</a>],\n' +
' <strong><span class="hljs-string">\'4. System\'</span></strong>: [<a href="#exit">Exit</a>, <a href="#print">Print</a>, <a href="#input">Input</a>, <a href="#commandlinearguments">Command_Line_Arguments</a>, <a href="#open">Open</a>, <a href="#paths">Path</a>, <a href="#oscommands">OS_Commands</a>],\n' +
' <strong><span class="hljs-string">\'5. Data\'</span></strong>: [<a href="#json">JSON</a>, <a href="#pickle">Pickle</a>, <a href="#csv">CSV</a>, <a href="#sqlite">SQLite</a>, <a href="#bytes">Bytes</a>, <a href="#struct">Struct</a>, <a href="#array">Array</a>, <a href="#memoryview">Memory_View</a>, <a href="#deque">Deque</a>],\n' +
' <strong><span class="hljs-string">\'6. Advanced\'</span></strong>: [<a href="#threading">Threading</a>, <a href="#operator">Operator</a>, <a href="#matchstatement">Match_Stmt</a>, <a href="#logging">Logging</a>, <a href="#introspection">Introspection</a>, <a href="#coroutines">Coroutines</a>],\n' +
' <strong><span class="hljs-string">\'6. Advanced\'</span></strong>: [<a href="#operator">Operator</a>, <a href="#matchstatement">Match_Stmt</a>, <a href="#logging">Logging</a>, <a href="#introspection">Introspection</a>, <a href="#threading">Threading</a>, <a href="#coroutines">Coroutines</a>],\n' +
' <strong><span class="hljs-string">\'7. Libraries\'</span></strong>: [<a href="#progressbar">Progress_Bar</a>, <a href="#plot">Plot</a>, <a href="#table">Table</a>, <a href="#consoleapp">Console_App</a>, <a href="#guiapp">GUI</a>, <a href="#scraping">Scraping</a>, <a href="#webapp">Web</a>, <a href="#profiling">Profile</a>],\n' +
' <strong><span class="hljs-string">\'8. Multimedia\'</span></strong>: [<a href="#numpy">NumPy</a>, <a href="#image">Image</a>, <a href="#animation">Animation</a>, <a href="#audio">Audio</a>, <a href="#synthesizer">Synthesizer</a>, <a href="#pygame">Pygame</a>, <a href="#pandas">Pandas</a>, <a href="#plotly">Plotly</a>]\n' +
'}\n';
@ -27,9 +27,9 @@ const TOC_MOBILE =
' <strong><span class="hljs-string">\'5. Data\'</span></strong>: [<a href="#json">JSON</a>, <a href="#pickle">Pickle</a>, <a href="#csv">CSV</a>, <a href="#sqlite">SQLite</a>,\n' +
' <a href="#bytes">Bytes</a>, <a href="#struct">Struct</a>, <a href="#array">Array</a>,\n' +
' <a href="#memoryview">Memory_View</a>, <a href="#deque">Deque</a>],\n' +
' <strong><span class="hljs-string">\'6. Advanced\'</span></strong>: [<a href="#threading">Threading</a>, <a href="#operator">Operator</a>,\n' +
' <a href="#matchstatement">Match_Stmt</a>, <a href="#logging">Logging</a>, \n' +
' <a href="#introspection">Introspection</a>, <a href="#coroutines">Coroutines</a>],\n' +
' <strong><span class="hljs-string">\'6. Advanced\'</span></strong>: [, <a href="#operator">Operator</a>, <a href="#matchstatement">Match_Stmt</a>,\n' +
' <a href="#logging">Logging</a>, <a href="#introspection">Introspection</a>,\n' +
' <a href="#threading">Threading</a>, <a href="#coroutines">Coroutines</a>],\n' +
' <strong><span class="hljs-string">\'7. Libraries\'</span></strong>: [<a href="#progressbar">Progress_Bar</a>, <a href="#plot">Plot</a>, <a href="#table">Table</a>,\n' +
' <a href="#consoleapp">Console_App</a>, <a href="#guiapp">GUI_App</a>,\n' +
' <a href="#scraping">Scraping</a>, <a href="#webapp">Web</a>, <a href="#profiling">Profiling</a>],\n' +

|||||||
100:0
Loading…
Cancel
Save