Browse Source

Argument parser, Operator, Web

pull/167/head
Jure Šorn 1 year ago
parent
commit
74fd89c224
3 changed files with 11 additions and 11 deletions
  1. 10
      README.md
  2. 10
      index.html
  3. 2
      pdf/index_for_pdf.html

10
README.md

@ -1553,7 +1553,7 @@ value = args.<name>
``` ```
* **Use `'help=<str>'` to set argument description that will be displayed in help message.** * **Use `'help=<str>'` to set argument description that will be displayed in help message.**
* **Use `'default=<el>'` to set the default value.**
* **Use `'default=<el>'` to set argument's default value.**
* **Use `'type=FileType(<mode>)'` for files. Accepts 'encoding', but 'newline' is None.** * **Use `'type=FileType(<mode>)'` for files. Accepts 'encoding', but 'newline' is None.**
@ -2177,7 +2177,7 @@ product_of_elems = functools.reduce(op.mul, <collection>)
union_of_sets = functools.reduce(op.or_, <coll_of_sets>) union_of_sets = functools.reduce(op.or_, <coll_of_sets>)
first_element = op.methodcaller('pop', 0)(<list>) first_element = op.methodcaller('pop', 0)(<list>)
``` ```
* **Bitwise operators require objects to have and(), or() and xor() special methods, unlike logical operators that work on all types of objects.**
* **Bitwise operators require objects to have and(), or(), xor() and invert() special methods, unlike logical operators that work on all types of objects.**
* **Also: `'<bool> = <bool> &|^ <bool>'` and `'<int> = <bool> &|^ <int>'`.** * **Also: `'<bool> = <bool> &|^ <bool>'` and `'<int> = <bool> &|^ <int>'`.**
@ -2191,7 +2191,7 @@ Introspection
### Attributes ### Attributes
```python ```python
<list> = dir(<object>) # Names of object's attributes (incl. methods).
<list> = dir(<object>) # Names of object's attributes (including methods).
<dict> = vars(<object>) # Dict of writable attributes. Also <obj>.__dict__. <dict> = vars(<object>) # Dict of writable attributes. Also <obj>.__dict__.
<bool> = hasattr(<object>, '<attr_name>') # Checks if getattr() raises an AttributeError. <bool> = hasattr(<object>, '<attr_name>') # Checks if getattr() raises an AttributeError.
value = getattr(<object>, '<attr_name>') # Raises AttributeError if attribute is missing. value = getattr(<object>, '<attr_name>') # Raises AttributeError if attribute is missing.
@ -2564,7 +2564,7 @@ def serve_json(sport):
return {'team': team, 'odds': [2.09, 3.74, 3.68]} return {'team': team, 'odds': [2.09, 3.74, 3.68]}
``` ```
#### Starts the app in its own thread and queries it with a post request:
#### Starts the app in its own thread and queries its REST API:
```python ```python
# $ pip3 install requests # $ pip3 install requests
>>> import threading, requests >>> import threading, requests
@ -3167,7 +3167,7 @@ Name: a, dtype: int64
``` ```
```python ```python
<Sr> = pd.concat(<coll_of_Sr>) # Concats multiple Series into one long Series.
<Sr> = pd.concat(<coll_of_Sr>) # Concats multiple series into one long Series.
<Sr> = <Sr>.combine_first(<Sr>) # Adds items that are not yet present. <Sr> = <Sr>.combine_first(<Sr>) # Adds items that are not yet present.
<Sr>.update(<Sr>) # Updates items that are already present. <Sr>.update(<Sr>) # Updates items that are already present.
``` ```

10
index.html

@ -1322,7 +1322,7 @@ value = args.&lt;name&gt;
<ul> <ul>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'help=&lt;str&gt;'</span></code> to set argument description that will be displayed in help message.</strong></li> <li><strong>Use <code class="python hljs"><span class="hljs-string">'help=&lt;str&gt;'</span></code> to set argument description that will be displayed in help message.</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'default=&lt;el&gt;'</span></code> to set the default value.</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'default=&lt;el&gt;'</span></code> to set argument's default value.</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'type=FileType(&lt;mode&gt;)'</span></code> for files. Accepts 'encoding', but 'newline' is None.</strong></li> <li><strong>Use <code class="python hljs"><span class="hljs-string">'type=FileType(&lt;mode&gt;)'</span></code> for files. Accepts 'encoding', but 'newline' is None.</strong></li>
</ul> </ul>
<div><h2 id="open"><a href="#open" name="open">#</a>Open</h2><p><strong>Opens the file and returns a corresponding file object.</strong></p><pre><code class="python language-python hljs">&lt;file&gt; = open(&lt;path&gt;, mode=<span class="hljs-string">'r'</span>, encoding=<span class="hljs-keyword">None</span>, newline=<span class="hljs-keyword">None</span>) <div><h2 id="open"><a href="#open" name="open">#</a>Open</h2><p><strong>Opens the file and returns a corresponding file object.</strong></p><pre><code class="python language-python hljs">&lt;file&gt; = open(&lt;path&gt;, mode=<span class="hljs-string">'r'</span>, encoding=<span class="hljs-keyword">None</span>, newline=<span class="hljs-keyword">None</span>)
@ -1800,7 +1800,7 @@ union_of_sets = functools.reduce(op.or_, &lt;coll_of_sets&gt;)
first_element = op.methodcaller(<span class="hljs-string">'pop'</span>, <span class="hljs-number">0</span>)(&lt;list&gt;) first_element = op.methodcaller(<span class="hljs-string">'pop'</span>, <span class="hljs-number">0</span>)(&lt;list&gt;)
</code></pre> </code></pre>
<ul> <ul>
<li><strong>Bitwise operators require objects to have and(), or() and xor() special methods, unlike logical operators that work on all types of objects.</strong></li>
<li><strong>Bitwise operators require objects to have and(), or(), xor() and invert() special methods, unlike logical operators that work on all types of objects.</strong></li>
<li><strong>Also: <code class="python hljs"><span class="hljs-string">'&lt;bool&gt; = &lt;bool&gt; &amp;|^ &lt;bool&gt;'</span></code> and <code class="python hljs"><span class="hljs-string">'&lt;int&gt; = &lt;bool&gt; &amp;|^ &lt;int&gt;'</span></code>.</strong></li> <li><strong>Also: <code class="python hljs"><span class="hljs-string">'&lt;bool&gt; = &lt;bool&gt; &amp;|^ &lt;bool&gt;'</span></code> and <code class="python hljs"><span class="hljs-string">'&lt;int&gt; = &lt;bool&gt; &amp;|^ &lt;int&gt;'</span></code>.</strong></li>
</ul> </ul>
<div><h2 id="introspection"><a href="#introspection" name="introspection">#</a>Introspection</h2><pre><code class="python language-python hljs">&lt;list&gt; = dir() <span class="hljs-comment"># Names of local variables, functions, classes, etc.</span> <div><h2 id="introspection"><a href="#introspection" name="introspection">#</a>Introspection</h2><pre><code class="python language-python hljs">&lt;list&gt; = dir() <span class="hljs-comment"># Names of local variables, functions, classes, etc.</span>
@ -1808,7 +1808,7 @@ first_element = op.methodcaller(<span class="hljs-string">'pop'</span>, <span
&lt;dict&gt; = globals() <span class="hljs-comment"># Dict of global vars, etc. (incl. '__builtins__').</span> &lt;dict&gt; = globals() <span class="hljs-comment"># Dict of global vars, etc. (incl. '__builtins__').</span>
</code></pre></div> </code></pre></div>
<div><h3 id="attributes">Attributes</h3><pre><code class="python language-python hljs">&lt;list&gt; = dir(&lt;object&gt;) <span class="hljs-comment"># Names of object's attributes (incl. methods).</span>
<div><h3 id="attributes">Attributes</h3><pre><code class="python language-python hljs">&lt;list&gt; = dir(&lt;object&gt;) <span class="hljs-comment"># Names of object's attributes (including methods).</span>
&lt;dict&gt; = vars(&lt;object&gt;) <span class="hljs-comment"># Dict of writable attributes. Also &lt;obj&gt;.__dict__.</span> &lt;dict&gt; = vars(&lt;object&gt;) <span class="hljs-comment"># Dict of writable attributes. Also &lt;obj&gt;.__dict__.</span>
&lt;bool&gt; = hasattr(&lt;object&gt;, <span class="hljs-string">'&lt;attr_name&gt;'</span>) <span class="hljs-comment"># Checks if getattr() raises an AttributeError.</span> &lt;bool&gt; = hasattr(&lt;object&gt;, <span class="hljs-string">'&lt;attr_name&gt;'</span>) <span class="hljs-comment"># Checks if getattr() raises an AttributeError.</span>
value = getattr(&lt;object&gt;, <span class="hljs-string">'&lt;attr_name&gt;'</span>) <span class="hljs-comment"># Raises AttributeError if attribute is missing.</span> value = getattr(&lt;object&gt;, <span class="hljs-string">'&lt;attr_name&gt;'</span>) <span class="hljs-comment"># Raises AttributeError if attribute is missing.</span>
@ -2106,7 +2106,7 @@ app.run(host=<span class="hljs-keyword">None</span>, port=<span class="hljs-keyw
<span class="hljs-keyword">return</span> {<span class="hljs-string">'team'</span>: team, <span class="hljs-string">'odds'</span>: [<span class="hljs-number">2.09</span>, <span class="hljs-number">3.74</span>, <span class="hljs-number">3.68</span>]} <span class="hljs-keyword">return</span> {<span class="hljs-string">'team'</span>: team, <span class="hljs-string">'odds'</span>: [<span class="hljs-number">2.09</span>, <span class="hljs-number">3.74</span>, <span class="hljs-number">3.68</span>]}
</code></pre></div> </code></pre></div>
<div><h4 id="startstheappinitsownthreadandqueriesitwithapostrequest">Starts the app in its own thread and queries it with a post request:</h4><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install requests</span>
<div><h4 id="startstheappinitsownthreadandqueriesitsrestapi">Starts the app in its own thread and queries its REST API:</h4><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install requests</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> threading, requests <span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> threading, requests
<span class="hljs-meta">&gt;&gt;&gt; </span>threading.Thread(target=app.run, daemon=<span class="hljs-keyword">True</span>).start() <span class="hljs-meta">&gt;&gt;&gt; </span>threading.Thread(target=app.run, daemon=<span class="hljs-keyword">True</span>).start()
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">'http://localhost:5000/football/odds'</span> <span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">'http://localhost:5000/football/odds'</span>
@ -2588,7 +2588,7 @@ Name: a, dtype: int64
<pre><code class="python language-python hljs">&lt;Sr&gt; = &lt;Sr&gt; &gt; &lt;el/Sr&gt; <span class="hljs-comment"># Returns a Series of bools.</span> <pre><code class="python language-python hljs">&lt;Sr&gt; = &lt;Sr&gt; &gt; &lt;el/Sr&gt; <span class="hljs-comment"># Returns a Series of bools.</span>
&lt;Sr&gt; = &lt;Sr&gt; + &lt;el/Sr&gt; <span class="hljs-comment"># Items with non-matching keys get value NaN.</span> &lt;Sr&gt; = &lt;Sr&gt; + &lt;el/Sr&gt; <span class="hljs-comment"># Items with non-matching keys get value NaN.</span>
</code></pre> </code></pre>
<pre><code class="python language-python hljs">&lt;Sr&gt; = pd.concat(&lt;coll_of_Sr&gt;) <span class="hljs-comment"># Concats multiple Series into one long Series.</span>
<pre><code class="python language-python hljs">&lt;Sr&gt; = pd.concat(&lt;coll_of_Sr&gt;) <span class="hljs-comment"># Concats multiple series into one long Series.</span>
&lt;Sr&gt; = &lt;Sr&gt;.combine_first(&lt;Sr&gt;) <span class="hljs-comment"># Adds items that are not yet present.</span> &lt;Sr&gt; = &lt;Sr&gt;.combine_first(&lt;Sr&gt;) <span class="hljs-comment"># Adds items that are not yet present.</span>
&lt;Sr&gt;.update(&lt;Sr&gt;) <span class="hljs-comment"># Updates items that are already present.</span> &lt;Sr&gt;.update(&lt;Sr&gt;) <span class="hljs-comment"># Updates items that are already present.</span>
</code></pre> </code></pre>

2
pdf/index_for_pdf.html

@ -116,7 +116,7 @@
<strong>recursion, <a href="#lrucache">13</a></strong><br> <strong>recursion, <a href="#lrucache">13</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>, <a href="#operator">31</a></strong><br>
<strong>regular expressions, <a href="#regex">5</a>-<a href="#specialsequences">6</a></strong><br> <strong>regular expressions, <a href="#regex">5</a>-<a href="#specialsequences">6</a></strong><br>
<strong>requests library, <a href="#scrapespythonsurlversionnumberandlogofromitswikipediapage">35</a>, <a href="#startstheappinitsownthreadandqueriesitwithapostrequest">36</a></strong> </p>
<strong>requests library, <a href="#scrapespythonsurlversionnumberandlogofromitswikipediapage">35</a>, <a href="#startstheappinitsownthreadandqueriesitsrestapi">36</a></strong> </p>
<h3 id="s">S</h3> <h3 id="s">S</h3>
<p><strong>scope, <a href="#insidefunctiondefinition">10</a>, <a href="#nonlocal">12</a>, <a href="#complexexample">20</a></strong><br> <p><strong>scope, <a href="#insidefunctiondefinition">10</a>, <a href="#nonlocal">12</a>, <a href="#complexexample">20</a></strong><br>
<strong>scraping, <a href="#scraping">35</a>, <a href="#basicmariobrothersexample">43</a>, <a href="#dataframeencodedecodeplot">46</a>, <a href="#displaysalinechartoftotalcoronavirusdeathspermilliongroupedbycontinent">47</a>-<a href="#displaysamultiaxislinechartoftotalcoronaviruscasesandchangesinpricesofbitcoindowjonesandgold">48</a></strong><br> <strong>scraping, <a href="#scraping">35</a>, <a href="#basicmariobrothersexample">43</a>, <a href="#dataframeencodedecodeplot">46</a>, <a href="#displaysalinechartoftotalcoronavirusdeathspermilliongroupedbycontinent">47</a>-<a href="#displaysamultiaxislinechartoftotalcoronaviruscasesandchangesinpricesofbitcoindowjonesandgold">48</a></strong><br>

Loading…
Cancel
Save