Skip to content

Commit 5a48992

Browse files
committed
Small fixes
1 parent 45efec6 commit 5a48992

File tree

4 files changed

+95
-68
lines changed

4 files changed

+95
-68
lines changed

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -401,40 +401,40 @@ Format
401401

402402
### General Options
403403
```python
404-
{<el>:<10} # '<el> '
405-
{<el>:^10} # ' <el> '
406-
{<el>:>10} # ' <el>'
404+
{<el>:<10} # '<el> '
405+
{<el>:^10} # ' <el> '
406+
{<el>:>10} # ' <el>'
407407
```
408408

409409
```python
410-
{<el>:.<10} # '<el>......'
411-
{<el>:<0} # '<el>'
410+
{<el>:.<10} # '<el>......'
411+
{<el>:<0} # '<el>'
412412
```
413413

414414
### Strings
415415
**`'!r'` calls object's repr() method, instead of str(), to get a string.**
416416
```python
417-
{'abcde'!r:<10} # "'abcde' "
418-
{'abcde':.3} # 'abc'
419-
{'abcde':10.3} # 'abc '
417+
{'abcde'!r:<10} # "'abcde' "
418+
{'abcde':.3} # 'abc'
419+
{'abcde':10.3} # 'abc '
420420
```
421421

422422
### Numbers
423423
```python
424-
{ 123456:10,} # ' 123,456'
425-
{ 123456:10_} # ' 123_456'
426-
{ 123456:+10} # ' +123456'
427-
{-123456:=10} # '- 123456'
428-
{ 123456: } # ' 123456'
429-
{-123456: } # '-123456'
424+
{ 123456:10,} # ' 123,456'
425+
{ 123456:10_} # ' 123_456'
426+
{ 123456:+10} # ' +123456'
427+
{-123456:=10} # '- 123456'
428+
{ 123456: } # ' 123456'
429+
{-123456: } # '-123456'
430430
```
431431

432432
### Floats
433433
```python
434-
{1.23456:10.3} # ' 1.23'
435-
{1.23456:10.3f} # ' 1.235'
436-
{1.23456:10.3e} # ' 1.235e+00'
437-
{1.23456:10.3%} # ' 123.456%'
434+
{1.23456:10.3} # ' 1.23'
435+
{1.23456:10.3f} # ' 1.235'
436+
{1.23456:10.3e} # ' 1.235e+00'
437+
{1.23456:10.3%} # ' 123.456%'
438438
```
439439

440440
#### Comparison of float presentation types:
@@ -469,9 +469,9 @@ Format
469469

470470
### Ints
471471
```python
472-
{90:c} # 'Z'
473-
{90:X} # '5A'
474-
{90:b} # '1011010'
472+
{90:c} # 'Z'
473+
{90:X} # '5A'
474+
{90:b} # '1011010'
475475
```
476476

477477

@@ -1499,7 +1499,7 @@ Open
14991499
<file> = open('<path>', mode='r', encoding=None, newline=None)
15001500
```
15011501
* **`'encoding=None'` means default encoding is used, which is platform dependent. Best practice is to use `'encoding="utf-8"'` whenever possible.**
1502-
* **`'newline=None'` means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to the system's default line separator.**
1502+
* **`'newline=None'` means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.**
15031503
* **`'newline=""'` means no conversions take place, but input is still broken into chunks by readline() and readlines() on either '\n', '\r' or '\r\n'.**
15041504

15051505
### Modes
@@ -1800,13 +1800,13 @@ SQLite
18001800
**Server-less database engine that stores each database into separate file.**
18011801

18021802
### Connect
1803+
**Opens a connection to the database file. Creates a new file if path doesn't exist.**
18031804
```python
18041805
import sqlite3
18051806
db = sqlite3.connect('<path>') # Also ':memory:'.
18061807
...
18071808
db.close()
18081809
```
1809-
* **New database will be created if path doesn't exist.**
18101810

18111811
### Read
18121812
**Returned values can be of type str, int, float, bytes or None.**
@@ -1963,12 +1963,12 @@ Memory View
19631963
<mview> = memoryview(<bytes/bytearray/array>)
19641964
<num> = <mview>[<index>] # Returns an int or a float.
19651965
<mview> = <mview>[<slice>] # Mview with rearranged elements.
1966-
<mview> = <mview>.cast('<typecode>') # Casts a memoryview to a new format.
1966+
<mview> = <mview>.cast('<typecode>') # Casts memoryview to the new format.
19671967
<mview>.release() # Releases the object's memory buffer.
19681968
```
19691969

19701970
```python
1971-
<bin_file>.write(<mview>) # Writes mview to a binary file.
1971+
<bin_file>.write(<mview>) # Appends mview to the binary file.
19721972
<bytes> = bytes(<mview>) # Creates a new bytes object.
19731973
<bytes> = <bytes>.join(<coll_of_mviews>) # Joins mviews using bytes object as sep.
19741974
<list> = list(<mview>) # Returns list of ints or floats.

index.html

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -496,32 +496,32 @@
496496
<span class="hljs-string">'187'</span>
497497
</code></pre></div>
498498

499-
<div><h3 id="generaloptions">General Options</h3><pre><code class="python language-python hljs">{&lt;el&gt;:&lt;<span class="hljs-number">10</span>} <span class="hljs-comment"># '&lt;el&gt; '</span>
500-
{&lt;el&gt;:^<span class="hljs-number">10</span>} <span class="hljs-comment"># ' &lt;el&gt; '</span>
501-
{&lt;el&gt;:&gt;<span class="hljs-number">10</span>} <span class="hljs-comment"># ' &lt;el&gt;'</span>
499+
<div><h3 id="generaloptions">General Options</h3><pre><code class="python language-python hljs">{&lt;el&gt;:&lt;<span class="hljs-number">10</span>} <span class="hljs-comment"># '&lt;el&gt; '</span>
500+
{&lt;el&gt;:^<span class="hljs-number">10</span>} <span class="hljs-comment"># ' &lt;el&gt; '</span>
501+
{&lt;el&gt;:&gt;<span class="hljs-number">10</span>} <span class="hljs-comment"># ' &lt;el&gt;'</span>
502502
</code></pre></div>
503503

504-
<pre><code class="python language-python hljs">{&lt;el&gt;:.&lt;<span class="hljs-number">10</span>} <span class="hljs-comment"># '&lt;el&gt;......'</span>
505-
{&lt;el&gt;:&lt;<span class="hljs-number">0</span>} <span class="hljs-comment"># '&lt;el&gt;'</span>
504+
<pre><code class="python language-python hljs">{&lt;el&gt;:.&lt;<span class="hljs-number">10</span>} <span class="hljs-comment"># '&lt;el&gt;......'</span>
505+
{&lt;el&gt;:&lt;<span class="hljs-number">0</span>} <span class="hljs-comment"># '&lt;el&gt;'</span>
506506
</code></pre>
507-
<div><h3 id="strings">Strings</h3><p><strong><code class="python hljs"><span class="hljs-string">'!r'</span></code> calls object's repr() method, instead of str(), to get a string.</strong></p><pre><code class="python language-python hljs">{<span class="hljs-string">'abcde'</span>!r:&lt;<span class="hljs-number">10</span>} <span class="hljs-comment"># "'abcde' "</span>
508-
{<span class="hljs-string">'abcde'</span>:<span class="hljs-number">.3</span>} <span class="hljs-comment"># 'abc'</span>
509-
{<span class="hljs-string">'abcde'</span>:<span class="hljs-number">10.3</span>} <span class="hljs-comment"># 'abc '</span>
507+
<div><h3 id="strings">Strings</h3><p><strong><code class="python hljs"><span class="hljs-string">'!r'</span></code> calls object's repr() method, instead of str(), to get a string.</strong></p><pre><code class="python language-python hljs">{<span class="hljs-string">'abcde'</span>!r:&lt;<span class="hljs-number">10</span>} <span class="hljs-comment"># "'abcde' "</span>
508+
{<span class="hljs-string">'abcde'</span>:<span class="hljs-number">.3</span>} <span class="hljs-comment"># 'abc'</span>
509+
{<span class="hljs-string">'abcde'</span>:<span class="hljs-number">10.3</span>} <span class="hljs-comment"># 'abc '</span>
510510
</code></pre></div>
511511

512512

513-
<div><h3 id="numbers-1">Numbers</h3><pre><code class="python language-python hljs">{ <span class="hljs-number">123456</span>:<span class="hljs-number">10</span>,} <span class="hljs-comment"># ' 123,456'</span>
514-
{ <span class="hljs-number">123456</span>:<span class="hljs-number">10</span>_} <span class="hljs-comment"># ' 123_456'</span>
515-
{ <span class="hljs-number">123456</span>:+<span class="hljs-number">10</span>} <span class="hljs-comment"># ' +123456'</span>
516-
{<span class="hljs-number">-123456</span>:=<span class="hljs-number">10</span>} <span class="hljs-comment"># '- 123456'</span>
517-
{ <span class="hljs-number">123456</span>: } <span class="hljs-comment"># ' 123456'</span>
518-
{<span class="hljs-number">-123456</span>: } <span class="hljs-comment"># '-123456'</span>
513+
<div><h3 id="numbers-1">Numbers</h3><pre><code class="python language-python hljs">{ <span class="hljs-number">123456</span>:<span class="hljs-number">10</span>,} <span class="hljs-comment"># ' 123,456'</span>
514+
{ <span class="hljs-number">123456</span>:<span class="hljs-number">10</span>_} <span class="hljs-comment"># ' 123_456'</span>
515+
{ <span class="hljs-number">123456</span>:+<span class="hljs-number">10</span>} <span class="hljs-comment"># ' +123456'</span>
516+
{<span class="hljs-number">-123456</span>:=<span class="hljs-number">10</span>} <span class="hljs-comment"># '- 123456'</span>
517+
{ <span class="hljs-number">123456</span>: } <span class="hljs-comment"># ' 123456'</span>
518+
{<span class="hljs-number">-123456</span>: } <span class="hljs-comment"># '-123456'</span>
519519
</code></pre></div>
520520

521-
<div><h3 id="floats">Floats</h3><pre><code class="python language-python hljs">{<span class="hljs-number">1.23456</span>:<span class="hljs-number">10.3</span>} <span class="hljs-comment"># ' 1.23'</span>
522-
{<span class="hljs-number">1.23456</span>:<span class="hljs-number">10.3</span>f} <span class="hljs-comment"># ' 1.235'</span>
523-
{<span class="hljs-number">1.23456</span>:<span class="hljs-number">10.3</span>e} <span class="hljs-comment"># ' 1.235e+00'</span>
524-
{<span class="hljs-number">1.23456</span>:<span class="hljs-number">10.3</span>%} <span class="hljs-comment"># ' 123.456%'</span>
521+
<div><h3 id="floats">Floats</h3><pre><code class="python language-python hljs">{<span class="hljs-number">1.23456</span>:<span class="hljs-number">10.3</span>} <span class="hljs-comment"># ' 1.23'</span>
522+
{<span class="hljs-number">1.23456</span>:<span class="hljs-number">10.3</span>f} <span class="hljs-comment"># ' 1.235'</span>
523+
{<span class="hljs-number">1.23456</span>:<span class="hljs-number">10.3</span>e} <span class="hljs-comment"># ' 1.235e+00'</span>
524+
{<span class="hljs-number">1.23456</span>:<span class="hljs-number">10.3</span>%} <span class="hljs-comment"># ' 123.456%'</span>
525525
</code></pre></div>
526526

527527
<div><h4 id="comparisonoffloatpresentationtypes">Comparison of float presentation types:</h4><pre><code class="text language-text">+----------------+----------------+---------------+----------------+-----------------+
@@ -551,9 +551,9 @@
551551
| 567.89 | '5.7e+02' | '567.89' | '5.68e+02' | '56789.00%' |
552552
+----------------+----------------+---------------+----------------+-----------------+
553553
</code></pre>
554-
<div><h3 id="ints">Ints</h3><pre><code class="python language-python hljs">{<span class="hljs-number">90</span>:c} <span class="hljs-comment"># 'Z'</span>
555-
{<span class="hljs-number">90</span>:X} <span class="hljs-comment"># '5A'</span>
556-
{<span class="hljs-number">90</span>:b} <span class="hljs-comment"># '1011010'</span>
554+
<div><h3 id="ints">Ints</h3><pre><code class="python language-python hljs">{<span class="hljs-number">90</span>:c} <span class="hljs-comment"># 'Z'</span>
555+
{<span class="hljs-number">90</span>:X} <span class="hljs-comment"># '5A'</span>
556+
{<span class="hljs-number">90</span>:b} <span class="hljs-comment"># '1011010'</span>
557557
</code></pre></div>
558558

559559
<div><h2 id="numbers"><a href="#numbers" name="numbers">#</a>Numbers</h2><div><h3 id="types">Types</h3><pre><code class="python language-python hljs">&lt;int&gt; = int(&lt;float/str/bool&gt;) <span class="hljs-comment"># Or: math.floor(&lt;float&gt;)</span>
@@ -1337,7 +1337,7 @@
13371337
<span class="hljs-keyword">pass</span>
13381338
</code></pre></div>
13391339

1340-
<div><h2 id="print"><a href="#print" name="print">#</a>Print</h2><pre><code class="python language-python hljs">print(&lt;el_1&gt;, ..., sep=<span class="hljs-string">' '</span>, end=<span class="hljs-string">'\n'</span>, file=sys.stdout, flush=<span class="hljs-keyword">False</span>)
1340+
<div class="pagebreak"></div><div><h2 id="print"><a href="#print" name="print">#</a>Print</h2><pre><code class="python language-python hljs">print(&lt;el_1&gt;, ..., sep=<span class="hljs-string">' '</span>, end=<span class="hljs-string">'\n'</span>, file=sys.stdout, flush=<span class="hljs-keyword">False</span>)
13411341
</code></pre></div>
13421342

13431343
<ul>
@@ -1387,7 +1387,7 @@
13871387

13881388
<ul>
13891389
<li><strong><code class="python hljs"><span class="hljs-string">'encoding=None'</span></code> means default encoding is used, which is platform dependent. Best practice is to use <code class="python hljs"><span class="hljs-string">'encoding="utf-8"'</span></code> whenever possible.</strong></li>
1390-
<li><strong><code class="python hljs"><span class="hljs-string">'newline=None'</span></code> means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to the system's default line separator.</strong></li>
1390+
<li><strong><code class="python hljs"><span class="hljs-string">'newline=None'</span></code> means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.</strong></li>
13911391
<li><strong><code class="python hljs"><span class="hljs-string">'newline=""'</span></code> means no conversions take place, but input is still broken into chunks by readline() and readlines() on either '\n', '\r' or '\r\n'.</strong></li>
13921392
</ul>
13931393
<div><h3 id="modes">Modes</h3><ul>
@@ -1605,17 +1605,15 @@
16051605
writer.writerows(rows)
16061606
</code></pre></div>
16071607

1608-
<div><h2 id="sqlite"><a href="#sqlite" name="sqlite">#</a>SQLite</h2><p><strong>Server-less database engine that stores each database into separate file.</strong></p><div><h3 id="connect">Connect</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> sqlite3
1608+
<div><h2 id="sqlite"><a href="#sqlite" name="sqlite">#</a>SQLite</h2><p><strong>Server-less database engine that stores each database into separate file.</strong></p><div><h3 id="connect">Connect</h3><p><strong>Opens a connection to the database file. Creates a new file if path doesn't exist.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> sqlite3
16091609
db = sqlite3.connect(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># Also ':memory:'.</span>
16101610
...
16111611
db.close()
16121612
</code></pre></div></div>
16131613

16141614

16151615

1616-
<ul>
1617-
<li><strong>New database will be created if path doesn't exist.</strong></li>
1618-
</ul>
1616+
16191617
<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>
16201618
&lt;tuple&gt; = &lt;cursor&gt;.fetchone() <span class="hljs-comment"># Returns next row. Also next(&lt;cursor&gt;).</span>
16211619
&lt;list&gt; = &lt;cursor&gt;.fetchall() <span class="hljs-comment"># Returns remaining rows.</span>
@@ -1702,21 +1700,21 @@
17021700
(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
17031701
</code></pre></div>
17041702

1705-
<div><h3 id="format-2">Format</h3><div><h4 id="forstandardsizesstartformatstringwith">For standard sizes start format string with:</h4><ul>
1703+
<div><h3 id="format-2">Format</h3></div><div><h4 id="forstandardsizesstartformatstringwith">For standard sizes start format string with:</h4><ul>
17061704
<li><strong><code class="python hljs"><span class="hljs-string">'='</span></code> - native byte order</strong></li>
17071705
<li><strong><code class="python hljs"><span class="hljs-string">'&lt;'</span></code> - little-endian</strong></li>
17081706
<li><strong><code class="python hljs"><span class="hljs-string">'&gt;'</span></code> - big-endian</strong></li>
1709-
</ul><div><h4 id="integertypesusecapitalletterforunsignedtypestandardsizesareinbrackets">Integer types. Use capital letter for unsigned type. Standard sizes are in brackets:</h4><ul>
1707+
</ul></div><div><h4 id="integertypesusecapitalletterforunsignedtypestandardsizesareinbrackets">Integer types. Use capital letter for unsigned type. Standard sizes are in brackets:</h4><ul>
17101708
<li><strong><code class="python hljs"><span class="hljs-string">'x'</span></code> - pad byte</strong></li>
17111709
<li><strong><code class="python hljs"><span class="hljs-string">'b'</span></code> - char (1)</strong></li>
17121710
<li><strong><code class="python hljs"><span class="hljs-string">'h'</span></code> - short (2)</strong></li>
17131711
<li><strong><code class="python hljs"><span class="hljs-string">'i'</span></code> - int (4)</strong></li>
17141712
<li><strong><code class="python hljs"><span class="hljs-string">'l'</span></code> - long (4)</strong></li>
17151713
<li><strong><code class="python hljs"><span class="hljs-string">'q'</span></code> - long long (8)</strong></li>
1716-
</ul><div><h4 id="floatingpointtypes">Floating point types:</h4><ul>
1714+
</ul></div><div><h4 id="floatingpointtypes">Floating point types:</h4><ul>
17171715
<li><strong><code class="python hljs"><span class="hljs-string">'f'</span></code> - float (4)</strong></li>
17181716
<li><strong><code class="python hljs"><span class="hljs-string">'d'</span></code> - double (8)</strong></li>
1719-
</ul></div></div></div></div>
1717+
</ul></div>
17201718

17211719

17221720

@@ -1737,12 +1735,12 @@
17371735
</ul><pre><code class="python language-python hljs">&lt;mview&gt; = memoryview(&lt;bytes/bytearray/array&gt;)
17381736
&lt;num&gt; = &lt;mview&gt;[&lt;index&gt;] <span class="hljs-comment"># Returns an int or a float.</span>
17391737
&lt;mview&gt; = &lt;mview&gt;[&lt;slice&gt;] <span class="hljs-comment"># Mview with rearranged elements.</span>
1740-
&lt;mview&gt; = &lt;mview&gt;.cast(<span class="hljs-string">'&lt;typecode&gt;'</span>) <span class="hljs-comment"># Casts a memoryview to a new format.</span>
1738+
&lt;mview&gt; = &lt;mview&gt;.cast(<span class="hljs-string">'&lt;typecode&gt;'</span>) <span class="hljs-comment"># Casts memoryview to the new format.</span>
17411739
&lt;mview&gt;.release() <span class="hljs-comment"># Releases the object's memory buffer.</span>
17421740
</code></pre></div>
17431741

17441742

1745-
<pre><code class="python language-python hljs">&lt;bin_file&gt;.write(&lt;mview&gt;) <span class="hljs-comment"># Writes mview to a binary file.</span>
1743+
<pre><code class="python language-python hljs">&lt;bin_file&gt;.write(&lt;mview&gt;) <span class="hljs-comment"># Appends mview to the binary file.</span>
17461744
&lt;bytes&gt; = bytes(&lt;mview&gt;) <span class="hljs-comment"># Creates a new bytes object.</span>
17471745
&lt;bytes&gt; = &lt;bytes&gt;.join(&lt;coll_of_mviews&gt;) <span class="hljs-comment"># Joins mviews using bytes object as sep.</span>
17481746
&lt;list&gt; = list(&lt;mview&gt;) <span class="hljs-comment"># Returns list of ints or floats.</span>

0 commit comments

Comments
 (0)