Browse Source

Merge branch 'master' into pygame

pull/52/head
Jure Šorn 5 years ago
parent
commit
9fb92d2cf0
4 changed files with 54 additions and 50 deletions
  1. 44
      README.md
  2. 46
      index.html
  3. 4
      pdf/how_to_create_pdf.md
  4. 10
      web/script_2.js

44
README.md

@ -96,7 +96,7 @@ value = <dict>.pop(key) # Removes item or raises KeyErro
### Counter
```python
>>> from collections import Counter
>>> colors = ['blue', 'red', 'blue', 'red', 'blue']
>>> colors = ['blue', 'blue', 'blue', 'red', 'red']
>>> counter = Counter(colors)
>>> counter['yellow'] += 1
Counter({'blue': 3, 'red': 2, 'yellow': 1})
@ -377,7 +377,7 @@ import re
```
### Special Sequences
* **By default digits, whitespaces and alphanumerics from all alphabets are matched, unless `'flags=re.ASCII'` argument is used.**
* **By default digits, alphanumerics and whitespaces from all alphabets are matched, unless `'flags=re.ASCII'` argument is used.**
* **Use a capital letter for negation.**
```python
'\d' == '[0-9]' # Matches any digit.
@ -442,7 +442,7 @@ Format
#### Comparison of presentation types:
```text
+---------------+-----------------+-----------------+-----------------+-----------------+
| | {<real>} | {<real>:f} | {<real>:e} | {<real>:%} |
| | {<float>} | {<float>:f} | {<float>:e} | {<float>:%} |
+---------------+-----------------+-----------------+-----------------+-----------------+
| 0.000056789 | '5.6789e-05' | '0.000057' | '5.678900e-05' | '0.005679%' |
| 0.00056789 | '0.00056789' | '0.000568' | '5.678900e-04' | '0.056789%' |
@ -456,7 +456,7 @@ Format
```
```text
+---------------+-----------------+-----------------+-----------------+-----------------+
| | {<float>:.2} | {<real>:.2f} | {<real>:.2e} | {<real>:.2%} |
| | {<float>:.2} | {<float>:.2f} | {<float>:.2e} | {<float>:.2%} |
+---------------+-----------------+-----------------+-----------------+-----------------+
| 0.000056789 | '5.7e-05' | '0.00' | '5.68e-05' | '0.01%' |
| 0.00056789 | '0.00057' | '0.00' | '5.68e-04' | '0.06%' |
@ -541,7 +541,7 @@ shuffle(<list>)
Combinatorics
-------------
* **Every function returns an iterator.**
* **If you want to print the iterator, you need to pass it to the list() function!**
* **If you want to print the iterator, you need to pass it to the list() function first!**
```python
from itertools import product, combinations, combinations_with_replacement, permutations
@ -1093,7 +1093,7 @@ class MyComparable:
```python
class MyHashable:
def __init__(self, a):
self._a = copy.deepcopy(a)
self._a = a
@property
def a(self):
return self._a
@ -1146,7 +1146,7 @@ class Counter:
```
#### Python has many different iterator objects:
* **Objects returned by the [iter()](#iterator) function, such as list\_iterator and set\_iterator.**
* **Iterators returned by the [iter()](#iterator) function, such as list\_iterator and set\_iterator.**
* **Objects returned by the [itertools](#itertools) module, such as count, repeat and cycle.**
* **Generators returned by the [generator functions](#generator) and [generator expressions](#comprehension).**
* **File objects returned by the [open()](#open) function, etc.**
@ -1170,7 +1170,7 @@ class Counter:
```
### Context Manager
* **Enter() should lock the resources and (optionally) return an object.**
* **Enter() should lock the resources and optionally return an object.**
* **Exit() should release the resources.**
* **Any exception that happens inside the with block is passed to the exit() method.**
* **If it wishes to suppress the exception it must return a true value.**
@ -1205,8 +1205,9 @@ class MyIterable:
def __init__(self, a):
self.a = a
def __iter__(self):
for el in self.a:
yield el
return iter(self.a)
def __contains__(self, el):
return el in self.a
```
```python
@ -1336,7 +1337,7 @@ from functools import partial
LogicOp = Enum('LogicOp', {'AND': partial(lambda l, r: l and r),
'OR' : partial(lambda l, r: l or r)})
```
* **Another solution in this particular case is to use built-in functions `'and_'` and `'or_'` from the module [operator](#operator).**
* **Another solution in this particular case is to use built-in functions and\_() and or\_() from the module [operator](#operator).**
Exceptions
@ -1419,7 +1420,7 @@ BaseException
+-- StopIteration # Raised by next() when run on an empty iterator.
+-- TypeError # Raised when an argument is of wrong type.
+-- ValueError # When an argument is of right type but inappropriate value.
+-- UnicodeError # Raised when encoding/decoding strings from/to bytes fails.
+-- UnicodeError # Raised when encoding/decoding strings to/from bytes fails.
```
#### Collections and their exceptions:
@ -1589,7 +1590,7 @@ from glob import glob
```
```python
<str> = getcwd() # Returns current working directory.
<str> = getcwd() # Returns the current working directory.
<str> = path.join(<path>, ...) # Joins two or more pathname components.
<str> = path.abspath(<path>) # Returns absolute path.
```
@ -1663,7 +1664,7 @@ from pathlib import Path
OS Commands
-----------
### Files and Directories
* **Paths can be either strings, Paths, or DirEntry objects.**
* **Paths can be either strings, Paths or DirEntry objects.**
* **Functions report OS related errors by raising either OSError or one of its [subclasses](#exceptions-1).**
```python
@ -1671,7 +1672,7 @@ import os, shutil
```
```python
os.chdir(<path>) # Changes current working directory.
os.chdir(<path>) # Changes the current working directory.
os.mkdir(<path>, mode=0o777) # Creates a directory. Mode is in octal.
```
@ -1787,7 +1788,7 @@ import csv
<writer>.writerow(<collection>) # Encodes objects using `str(<el>)`.
<writer>.writerows(<coll_of_coll>) # Appends multiple rows.
```
* **File must be opened with `'newline=""'` argument, or an extra '\r' will be added to every '\n' on platforms that use '\r\n' linendings!**
* **File must be opened with `'newline=""'` argument, or an extra '\r' will be added to every '\n' on platforms that use '\r\n' line endings!**
### Parameters
* **`'dialect'` - Master parameter that sets the default values.**
@ -1846,9 +1847,9 @@ db.close()
### Read
**Returned values can be of type str, int, float, bytes or None.**
```python
<cursor> = db.execute('<query>') # Can raise sqlite3.OperationalError.
<cursor> = db.execute('<query>') # Raises a subclass of sqlite3.Error.
<tuple> = <cursor>.fetchone() # Returns next row. Also next(<cursor>).
<list> = <cursor>.fetchall() # Returns remaining rows.
<list> = <cursor>.fetchall() # Returns remaining rows. Also list(<cursor>).
```
### Write
@ -1889,7 +1890,7 @@ db.executemany('<query>', <coll_of_above>) # Runs execute() many times.
from mysql import connector
db = connector.connect(host=<str>, user=<str>, password=<str>, database=<str>)
<cursor> = db.cursor()
<cursor>.execute('<query>') # Only cursor has execute method.
<cursor>.execute('<query>') # Raises a subclass of mysql.connector.Error.
<cursor>.execute('<query>', <list/tuple>) # Replaces '%s's in query with values.
<cursor>.execute('<query>', <dict/namedtuple>) # Replaces '%(<key>)s's with values.
```
@ -1958,7 +1959,7 @@ b'\x00\x01\x00\x02\x00\x00\x00\x03'
```
### Format
#### For standard sizes start format string with:
#### For standard type sizes start format string with:
* **`'='` - native byte order**
* **`'<'` - little-endian**
* **`'>'` - big-endian (also `'!'`)**
@ -1982,8 +1983,9 @@ Array
```python
from array import array
<array> = array('<typecode>', <collection>) # Array from coll. of numbers.
<array> = array('<typecode>', <collection>) # Array from collection of numbers.
<array> = array('<typecode>', <bytes>) # Array from bytes object.
<array> = array('<typecode>', <array>) # Treats array as a sequence of numbers.
<bytes> = bytes(<array>) # Or: <array>.tobytes()
```

46
index.html

@ -279,7 +279,7 @@ value = &lt;dict&gt;.pop(key) <span class="hljs-comment"
{k: v <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> &lt;dict&gt;.items() <span class="hljs-keyword">if</span> k <span class="hljs-keyword">in</span> keys} <span class="hljs-comment"># Returns a dictionary, filtered by keys.</span>
</code></pre>
<div><h3 id="counter">Counter</h3><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> Counter
<span class="hljs-meta">&gt;&gt;&gt; </span>colors = [<span class="hljs-string">'blue'</span>, <span class="hljs-string">'red'</span>, <span class="hljs-string">'blue'</span>, <span class="hljs-string">'red'</span>, <span class="hljs-string">'blue'</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>colors = [<span class="hljs-string">'blue'</span>, <span class="hljs-string">'blue'</span>, <span class="hljs-string">'blue'</span>, <span class="hljs-string">'red'</span>, <span class="hljs-string">'red'</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>counter = Counter(colors)
<span class="hljs-meta">&gt;&gt;&gt; </span>counter[<span class="hljs-string">'yellow'</span>] += <span class="hljs-number">1</span>
Counter({<span class="hljs-string">'blue'</span>: <span class="hljs-number">3</span>, <span class="hljs-string">'red'</span>: <span class="hljs-number">2</span>, <span class="hljs-string">'yellow'</span>: <span class="hljs-number">1</span>})
@ -484,7 +484,7 @@ to_exclusive = &lt;range&gt;.stop
</code></pre></div>
<div><h3 id="specialsequences">Special Sequences</h3><ul>
<li><strong>By default digits, whitespaces and alphanumerics from all alphabets are matched, unless <code class="python hljs"><span class="hljs-string">'flags=re.ASCII'</span></code> argument is used.</strong></li>
<li><strong>By default digits, alphanumerics and whitespaces from all alphabets are matched, unless <code class="python hljs"><span class="hljs-string">'flags=re.ASCII'</span></code> argument is used.</strong></li>
<li><strong>Use a capital letter for negation.</strong></li>
</ul><pre><code class="python language-python hljs"><span class="hljs-string">'\d'</span> == <span class="hljs-string">'[0-9]'</span> <span class="hljs-comment"># Matches any digit.</span>
<span class="hljs-string">'\w'</span> == <span class="hljs-string">'[a-zA-Z0-9_]'</span> <span class="hljs-comment"># Matches any alphanumeric.</span>
@ -533,7 +533,7 @@ to_exclusive = &lt;range&gt;.stop
</code></pre></div>
<div><h4 id="comparisonofpresentationtypes">Comparison of presentation types:</h4><pre><code class="text language-text">+---------------+-----------------+-----------------+-----------------+-----------------+
| | {&lt;real&gt;} | {&lt;real&gt;:f} | {&lt;real&gt;:e} | {&lt;real&gt;:%} |
| | {&lt;float&gt;} | {&lt;float&gt;:f} | {&lt;float&gt;:e} | {&lt;float&gt;:%} |
+---------------+-----------------+-----------------+-----------------+-----------------+
| 0.000056789 | '5.6789e-05' | '0.000057' | '5.678900e-05' | '0.005679%' |
| 0.00056789 | '0.00056789' | '0.000568' | '5.678900e-04' | '0.056789%' |
@ -547,7 +547,7 @@ to_exclusive = &lt;range&gt;.stop
</code></pre></div>
<pre><code class="text language-text">+---------------+-----------------+-----------------+-----------------+-----------------+
| | {&lt;float&gt;:.2} | {&lt;real&gt;:.2f} | {&lt;real&gt;:.2e} | {&lt;real&gt;:.2%} |
| | {&lt;float&gt;:.2} | {&lt;float&gt;:.2f} | {&lt;float&gt;:.2e} | {&lt;float&gt;:.2%} |
+---------------+-----------------+-----------------+-----------------+-----------------+
| 0.000056789 | '5.7e-05' | '0.00' | '5.68e-05' | '0.01%' |
| 0.00056789 | '0.00057' | '0.00' | '5.68e-04' | '0.06%' |
@ -613,7 +613,7 @@ shuffle(&lt;list&gt;)
<div><h2 id="combinatorics"><a href="#combinatorics" name="combinatorics">#</a>Combinatorics</h2><ul>
<li><strong>Every function returns an iterator.</strong></li>
<li><strong>If you want to print the iterator, you need to pass it to the list() function!</strong></li>
<li><strong>If you want to print the iterator, you need to pass it to the list() function first!</strong></li>
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> itertools <span class="hljs-keyword">import</span> product, combinations, combinations_with_replacement, permutations
</code></pre></div>
@ -1041,7 +1041,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
<li><strong>That is why Python automatically makes classes unhashable if you only implement eq().</strong></li>
</ul><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyHashable</span>:</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, a)</span>:</span>
self._a = copy.deepcopy(a)
self._a = a
<span class="hljs-meta"> @property</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">a</span><span class="hljs-params">(self)</span>:</span>
<span class="hljs-keyword">return</span> self._a
@ -1093,7 +1093,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
</code></pre>
<div><h4 id="pythonhasmanydifferentiteratorobjects">Python has many different iterator objects:</h4><ul>
<li><strong>Objects returned by the <a href="#iterator">iter()</a> function, such as list_iterator and set_iterator.</strong></li>
<li><strong>Iterators returned by the <a href="#iterator">iter()</a> function, such as list_iterator and set_iterator.</strong></li>
<li><strong>Objects returned by the <a href="#itertools">itertools</a> module, such as count, repeat and cycle.</strong></li>
<li><strong>Generators returned by the <a href="#generator">generator functions</a> and <a href="#comprehension">generator expressions</a>.</strong></li>
<li><strong>File objects returned by the <a href="#open">open()</a> function, etc.</strong></li>
@ -1116,7 +1116,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
</code></pre>
<div><h3 id="contextmanager">Context Manager</h3><ul>
<li><strong>Enter() should lock the resources and (optionally) return an object.</strong></li>
<li><strong>Enter() should lock the resources and optionally return an object.</strong></li>
<li><strong>Exit() should release the resources.</strong></li>
<li><strong>Any exception that happens inside the with block is passed to the exit() method.</strong></li>
<li><strong>If it wishes to suppress the exception it must return a true value.</strong> </li>
@ -1144,8 +1144,9 @@ Hello World!
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, a)</span>:</span>
self.a = a
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__iter__</span><span class="hljs-params">(self)</span>:</span>
<span class="hljs-keyword">for</span> el <span class="hljs-keyword">in</span> self.a:
<span class="hljs-keyword">yield</span> el
<span class="hljs-keyword">return</span> iter(self.a)
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__contains__</span><span class="hljs-params">(self, el)</span>:</span>
<span class="hljs-keyword">return</span> el <span class="hljs-keyword">in</span> self.a
</code></pre></div></div>
@ -1265,7 +1266,7 @@ LogicOp = Enum(<span class="hljs-string">'LogicOp'</span>, {<span class="hljs-st
</code></pre></div>
<ul>
<li><strong>Another solution in this particular case is to use built-in functions <code class="python hljs"><span class="hljs-string">'and_'</span></code> and <code class="python hljs"><span class="hljs-string">'or_'</span></code> from the module <a href="#operator">operator</a>.</strong></li>
<li><strong>Another solution in this particular case is to use built-in functions and_() and or_() from the module <a href="#operator">operator</a>.</strong></li>
</ul>
<div><h2 id="exceptions"><a href="#exceptions" name="exceptions">#</a>Exceptions</h2><div><h3 id="basicexample">Basic Example</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">try</span>:
&lt;code&gt;
@ -1333,7 +1334,7 @@ error_msg = traceback.format_exception(exc_type, &lt;name&gt;, &lt;name&gt;.__tr
+-- StopIteration # Raised by next() when run on an empty iterator.
+-- TypeError # Raised when an argument is of wrong type.
+-- ValueError # When an argument is of right type but inappropriate value.
+-- UnicodeError # Raised when encoding/decoding strings from/to bytes fails.
+-- UnicodeError # Raised when encoding/decoding strings to/from bytes fails.
</code></pre></div>
<div><h4 id="collectionsandtheirexceptions">Collections and their exceptions:</h4><pre><code class="text language-text">+-----------+------------+------------+------------+
@ -1469,7 +1470,7 @@ value = args.&lt;name&gt;
<span class="hljs-keyword">from</span> glob <span class="hljs-keyword">import</span> glob
</code></pre></div>
<pre><code class="python language-python hljs">&lt;str&gt; = getcwd() <span class="hljs-comment"># Returns current working directory.</span>
<pre><code class="python language-python hljs">&lt;str&gt; = getcwd() <span class="hljs-comment"># Returns the current working directory.</span>
&lt;str&gt; = path.join(&lt;path&gt;, ...) <span class="hljs-comment"># Joins two or more pathname components.</span>
&lt;str&gt; = path.abspath(&lt;path&gt;) <span class="hljs-comment"># Returns absolute path.</span>
</code></pre>
@ -1516,14 +1517,14 @@ value = args.&lt;name&gt;
&lt;file&gt; = open(&lt;Path&gt;) <span class="hljs-comment"># Opens the file and returns file object.</span>
</code></pre>
<div><h2 id="oscommands"><a href="#oscommands" name="oscommands">#</a>OS Commands</h2><div><h3 id="filesanddirectories">Files and Directories</h3><ul>
<li><strong>Paths can be either strings, Paths, or DirEntry objects.</strong></li>
<li><strong>Paths can be either strings, Paths or DirEntry objects.</strong></li>
<li><strong>Functions report OS related errors by raising either OSError or one of its <a href="#exceptions-1">subclasses</a>.</strong></li>
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> os, shutil
</code></pre></div></div>
<pre><code class="python language-python hljs">os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes current working directory.</span>
<pre><code class="python language-python hljs">os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes the current working directory.</span>
os.mkdir(&lt;path&gt;, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates a directory. Mode is in octal.</span>
</code></pre>
<pre><code class="python language-python hljs">shutil.copy(from, to) <span class="hljs-comment"># Copies the file. 'to' can be a directory.</span>
@ -1603,7 +1604,7 @@ CompletedProcess(args=[<span class="hljs-string">'bc'</span>, <span class="hljs-
</code></pre></div>
<ul>
<li><strong>File must be opened with <code class="python hljs"><span class="hljs-string">'newline=""'</span></code> argument, or an extra '\r' will be added to every '\n' on platforms that use '\r\n' linendings!</strong></li>
<li><strong>File must be opened with <code class="python hljs"><span class="hljs-string">'newline=""'</span></code> argument, or an extra '\r' will be added to every '\n' on platforms that use '\r\n' line endings!</strong></li>
</ul>
<div><h3 id="parameters">Parameters</h3><ul>
<li><strong><code class="python hljs"><span class="hljs-string">'dialect'</span></code> - Master parameter that sets the default values.</strong></li>
@ -1649,9 +1650,9 @@ db.close()
<div><h3 id="read-1">Read</h3><p><strong>Returned values can be of type str, int, float, bytes or None.</strong></p><pre><code class="python language-python hljs">&lt;cursor&gt; = db.execute(<span class="hljs-string">'&lt;query&gt;'</span>) <span class="hljs-comment"># Can raise sqlite3.OperationalError.</span>
<div><h3 id="read-1">Read</h3><p><strong>Returned values can be of type str, int, float, bytes or None.</strong></p><pre><code class="python language-python hljs">&lt;cursor&gt; = db.execute(<span class="hljs-string">'&lt;query&gt;'</span>) <span class="hljs-comment"># Raises a subclass of sqlite3.Error.</span>
&lt;tuple&gt; = &lt;cursor&gt;.fetchone() <span class="hljs-comment"># Returns next row. Also next(&lt;cursor&gt;).</span>
&lt;list&gt; = &lt;cursor&gt;.fetchall() <span class="hljs-comment"># Returns remaining rows.</span>
&lt;list&gt; = &lt;cursor&gt;.fetchall() <span class="hljs-comment"># Returns remaining rows. Also list(&lt;cursor&gt;).</span>
</code></pre></div>
@ -1684,7 +1685,7 @@ db.executemany(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;coll_of_abo
<span class="hljs-keyword">from</span> mysql <span class="hljs-keyword">import</span> connector
db = connector.connect(host=&lt;str&gt;, user=&lt;str&gt;, password=&lt;str&gt;, database=&lt;str&gt;)
&lt;cursor&gt; = db.cursor()
&lt;cursor&gt;.execute(<span class="hljs-string">'&lt;query&gt;'</span>) <span class="hljs-comment"># Only cursor has execute method.</span>
&lt;cursor&gt;.execute(<span class="hljs-string">'&lt;query&gt;'</span>) <span class="hljs-comment"># Raises a subclass of mysql.connector.Error.</span>
&lt;cursor&gt;.execute(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;list/tuple&gt;) <span class="hljs-comment"># Replaces '%s's in query with values.</span>
&lt;cursor&gt;.execute(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;dict/namedtuple&gt;) <span class="hljs-comment"># Replaces '%(&lt;key&gt;)s's with values.</span>
</code></pre></div>
@ -1735,11 +1736,11 @@ db = connector.connect(host=&lt;str&gt;, user=&lt;str&gt;, password=&lt;str&gt;,
(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
</code></pre></div>
<div><h3 id="format-2">Format</h3></div><div><h4 id="forstandardsizesstartformatstringwith">For standard sizes start format string with:</h4><ul>
<div><h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesstartformatstringwith">For standard type sizes start format string with:</h4><ul>
<li><strong><code class="python hljs"><span class="hljs-string">'='</span></code> - native byte order</strong></li>
<li><strong><code class="python hljs"><span class="hljs-string">'&lt;'</span></code> - little-endian</strong></li>
<li><strong><code class="python hljs"><span class="hljs-string">'&gt;'</span></code> - big-endian (also <code class="python hljs"><span class="hljs-string">'!'</span></code>)</strong></li>
</ul></div><div><h4 id="integertypesuseacapitalletterforunsignedtypestandardsizesareinbrackets">Integer types. Use a capital letter for unsigned type. Standard sizes are in brackets:</h4><ul>
</ul></div></div><div><h4 id="integertypesuseacapitalletterforunsignedtypestandardsizesareinbrackets">Integer types. Use a capital letter for unsigned type. Standard sizes are in brackets:</h4><ul>
<li><strong><code class="python hljs"><span class="hljs-string">'x'</span></code> - pad byte</strong></li>
<li><strong><code class="python hljs"><span class="hljs-string">'b'</span></code> - char (1)</strong></li>
<li><strong><code class="python hljs"><span class="hljs-string">'h'</span></code> - short (2)</strong></li>
@ -1757,8 +1758,9 @@ db = connector.connect(host=&lt;str&gt;, user=&lt;str&gt;, password=&lt;str&gt;,
<div><h2 id="array"><a href="#array" name="array">#</a>Array</h2><p><strong>List that can only hold numbers of a predefined type. Available types and their sizes in bytes are listed above.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> array <span class="hljs-keyword">import</span> array
&lt;array&gt; = array(<span class="hljs-string">'&lt;typecode&gt;'</span>, &lt;collection&gt;) <span class="hljs-comment"># Array from coll. of numbers.</span>
&lt;array&gt; = array(<span class="hljs-string">'&lt;typecode&gt;'</span>, &lt;collection&gt;) <span class="hljs-comment"># Array from collection of numbers.</span>
&lt;array&gt; = array(<span class="hljs-string">'&lt;typecode&gt;'</span>, &lt;bytes&gt;) <span class="hljs-comment"># Array from bytes object.</span>
&lt;array&gt; = array(<span class="hljs-string">'&lt;typecode&gt;'</span>, &lt;array&gt;) <span class="hljs-comment"># Treats array as a sequence of numbers.</span>
&lt;bytes&gt; = bytes(&lt;array&gt;) <span class="hljs-comment"># Or: &lt;array&gt;.tobytes()</span>
</code></pre></div>

4
pdf/how_to_create_pdf.md

@ -21,7 +21,7 @@ Printing to PDF
* Run `./parse.js` again.
* Open `index.html` in text editor and first remove element `<p><br></p>` before the `<h1>Libraries</h1>`.
* Then replace the footer and last three `<br>` elements with contents of `pdf/index_for_pdf_print.html` file and save.
* Change all links in text to normal text. They can be found with this regex: `<strong>.*a href.*</strong>`.
* Change all links in text to normal text and optionally add a page number after '(p. <num>)'. Links can be found with this regex: `<strong>.*a href.*</strong>`.
* Open `index.html` in Chrome.
* Change brightness of elements by right clicking on them and selecting inspect. Then click on the rectangle that represents color and toggle the color space to HSLA by clicking on the button with two vertical arrows.
* Change lightness (L) percentage to:
@ -43,7 +43,7 @@ Adding headers and footers to PDF (the same for both files)
* In 'Change page size' section select 'A4' for 'Page Sizes' set 'XOffset' to '0.1 in' and select page range All.
* Select 'Edit PDF' tab and add headers and footers by clicking 'Header & Footer' button, selecting a preset from 'Saved Settings' dropdown menu and clicking ok. Repeat the process for each preset.
* If presets get lost, the font and the margins are as follow: Borders: left-line: 0.6, left-text: 0.8, top-line: 11.4, bottom-text: 0.27, right-text-odd: 0.57, font-name: menlo, font-size: 8.
* Set title and author by selecting 'File/Propertiess...'.
* Set title and author by selecting 'File/Properties...'.
* Save.
Printing the PDF

10
web/script_2.js

@ -105,12 +105,12 @@ const DIAGRAM_4_B =
const DIAGRAM_5_A =
"+---------------+-----------------+-----------------+-----------------+-----------------+\n" +
"| | {<real>} | {<real>:f} | {<real>:e} | {<real>:%} |\n" +
"| | {<float>} | {<float>:f} | {<float>:e} | {<float>:%} |\n" +
"+---------------+-----------------+-----------------+-----------------+-----------------+\n";
const DIAGRAM_5_B =
"┏━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┓\n" +
"┃ │ {&lt;real&gt;} │ {&lt;real&gt;:f} │ {&lt;real&gt;:e} │ {&lt;real&gt;:%} ┃\n" +
"┃ │ {&lt;float&gt;} │ {&lt;float&gt;:f} │ {&lt;float&gt;:e} │ {&lt;float&gt;:%} ┃\n" +
"┠───────────────┼─────────────────┼─────────────────┼─────────────────┼─────────────────┨\n" +
"┃ 0.000056789 │ '5.6789e-05' │ '0.000057' │ '5.678900e-05' │ '0.005679%' ┃\n" +
"┃ 0.00056789 │ '0.00056789' │ '0.000568' │ '5.678900e-04' │ '0.056789%' ┃\n" +
@ -124,12 +124,12 @@ const DIAGRAM_5_B =
const DIAGRAM_6_A =
"+---------------+-----------------+-----------------+-----------------+-----------------+\n" +
"| | {<float>:.2} | {<real>:.2f} | {<real>:.2e} | {<real>:.2%} |\n" +
"| | {<float>:.2} | {<float>:.2f} | {<float>:.2e} | {<float>:.2%} |\n" +
"+---------------+-----------------+-----------------+-----------------+-----------------+\n";
const DIAGRAM_6_B =
"┏━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┓\n" +
"┃ │ {&lt;float&gt;:.2} │ {&lt;real&gt;:.2f} │ {&lt;real&gt;:.2e} │ {&lt;real&gt;:.2%} ┃\n" +
"┃ │ {&lt;float&gt;:.2} │ {&lt;float&gt;:.2f} │ {&lt;float&gt;:.2e} │ {&lt;float&gt;:.2%} ┃\n" +
"┠───────────────┼─────────────────┼─────────────────┼─────────────────┼─────────────────┨\n" +
"┃ 0.000056789 │ '5.7e-05' │ '0.00' │ '5.68e-05' │ '0.01%' ┃\n" +
"┃ 0.00056789 │ '0.00057' │ '0.00' │ '5.68e-04' │ '0.06%' ┃\n" +
@ -183,7 +183,7 @@ const DIAGRAM_8_B =
" ├── StopIteration <span class='hljs-comment'># Raised by next() when run on an empty iterator.</span>\n" +
" ├── TypeError <span class='hljs-comment'># Raised when an argument is of wrong type.</span>\n" +
" └── ValueError <span class='hljs-comment'># When an argument is of right type but inappropriate value.</span>\n" +
" └── UnicodeError <span class='hljs-comment'># Raised when encoding/decoding strings from/to bytes fails.</span>\n";
" └── UnicodeError <span class='hljs-comment'># Raised when encoding/decoding strings to/from bytes fails.</span>\n";
const DIAGRAM_9_A =
'+------------------+--------------+--------------+--------------+\n' +

Loading…
Cancel
Save