|
213 | 213 | <strong><span class="hljs-string"><span class="hljs-string">'1. Collections'</span></span></strong>: [<a href="#list">List</a>, <a href="#dictionary">Dictionary</a>, <a href="#set">Set</a>, <a href="#tuple">Tuple</a>, <a href="#range">Range</a>, <a href="#enumerate">Enumerate</a>, <a href="#iterator">Iterator</a>, <a href="#generator">Generator</a>],
|
214 | 214 | <strong><span class="hljs-string"><span class="hljs-string">'2. Types'</span></span></strong>: [<a href="#type">Type</a>, <a href="#string">String</a>, <a href="#regex">Regular_Exp</a>, <a href="#format">Format</a>, <a href="#numbers">Numbers</a>, <a href="#combinatorics">Combinatorics</a>, <a href="#datetime">Datetime</a>],
|
215 | 215 | <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="#closure">Closure</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">Exceptions</a>],
|
216 |
| - <strong><span class="hljs-string"><span class="hljs-string">'4. System'</span></span></strong>: [<a href="#print">Print</a>, <a href="#input">Input</a>, <a href="#commandlinearguments">Command_Line_Arguments</a>, <a href="#open">Open</a>, <a href="#path">Path</a>, <a href="#commandexecution">Command_Execution</a>], |
| 216 | + <strong><span class="hljs-string"><span class="hljs-string">'4. System'</span></span></strong>: [<a href="#print">Print</a>, <a href="#input">Input</a>, <a href="#commandlinearguments">Command_Line_Arguments</a>, <a href="#open">Open</a>, <a href="#path">Path</a>, <a href="#oscommands">Command_Execution</a>], |
217 | 217 | <strong><span class="hljs-string"><span class="hljs-string">'5. Data'</span></span></strong>: [<a href="#csv">CSV</a>, <a href="#sqlite">SQLite</a>, <a href="#json">JSON</a>, <a href="#pickle">Pickle</a>, <a href="#bytes">Bytes</a>, <a href="#struct">Struct</a>, <a href="#array">Array</a>, <a href="#memoryview">MemoryView</a>, <a href="#deque">Deque</a>],
|
218 | 218 | <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="#introspection">Introspection</a>, <a href="#metaprograming">Metaprograming</a>, <a href="#eval">Eval</a>, <a href="#coroutine">Coroutine</a>],
|
219 | 219 | <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="#curses">Curses</a>, <a href="#logging">Logging</a>, <a href="#scraping">Scraping</a>, <a href="#web">Web</a>, <a href="#profiling">Profile</a>,
|
|
1469 | 1469 | <Path> = <Path>.parent <span class="hljs-comment"># Returns path without final component.</span>
|
1470 | 1470 | <file> = open(<Path>) <span class="hljs-comment"># Opens the file and returns a file object.</span>
|
1471 | 1471 | </code></pre>
|
1472 |
| -<div><h2 id="commandexecution"><a href="#commandexecution" name="commandexecution">#</a>Command Execution</h2><div><h3 id="filesanddirectories">Files and Directories</h3><ul> |
| 1472 | +<div><h2 id="oscommands"><a href="#oscommands" name="oscommands">#</a>OS Commands</h2><div><h3 id="filesanddirectories">Files and Directories</h3><ul> |
1473 | 1473 | <li><strong>Paths can be either strings, Paths, or DirEntry objects.</strong></li>
|
1474 | 1474 | <li><strong>Functions report OS related errors by raising either OSError or one of its <a href="#exceptions-1">subclasses</a>.</strong></li>
|
1475 | 1475 | </ul><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> os, shutil
|
|
1515 | 1515 | <span class="hljs-number">0</span>
|
1516 | 1516 | </code></pre></div>
|
1517 | 1517 |
|
1518 |
| -<div><h2 id="csv"><a href="#csv" name="csv">#</a>CSV</h2><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> csv |
| 1518 | +<div><h2 id="csv"><a href="#csv" name="csv">#</a>CSV</h2><p><strong>Text file format for storing spreadsheets.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> csv |
1519 | 1519 | </code></pre></div>
|
1520 | 1520 |
|
| 1521 | + |
1521 | 1522 | <div><h3 id="read">Read</h3><pre><code class="python language-python hljs"><reader> = csv.reader(<file>, dialect=<span class="hljs-string">'excel'</span>, delimiter=<span class="hljs-string">','</span>)
|
1522 | 1523 | <list> = next(<reader>) <span class="hljs-comment"># Returns next row as a list of strings.</span>
|
1523 | 1524 | <list> = list(<reader>) <span class="hljs-comment"># Returns list of remaining rows.</span>
|
|
1728 | 1729 |
|
1729 | 1730 |
|
1730 | 1731 | <div><h2 id="memoryview"><a href="#memoryview" name="memoryview">#</a>Memory View</h2><ul>
|
1731 |
| -<li><strong>Memory View is a seqence that points to the memory of bytes, bytearray or array objects.</strong></li> |
1732 |
| -<li><strong>Each element can reference a single or multiple consecutive bytes.</strong></li> |
1733 |
| -<li><strong>Referenced elements can be narrowed down with slicing.</strong></li> |
| 1732 | +<li><strong>A seqence object that points to the memory of another object.</strong></li> |
| 1733 | +<li><strong>Each element can reference a single or multiple consecutive bytes, depending on format.</strong></li> |
| 1734 | +<li><strong>Order and number of elements can be changed with slicing.</strong></li> |
1734 | 1735 | </ul><pre><code class="python language-python hljs"><mview> = memoryview(<bytes/bytearray/array>)
|
1735 | 1736 | <num> = <mview>[<index>] <span class="hljs-comment"># Can be int or float.</span>
|
1736 | 1737 | <mview> = <mview>[<slice>] <span class="hljs-comment"># Mview with rearanged elements.</span>
|
1737 |
| -<mview> = <mview>.cast(<span class="hljs-string">'<typecode>'</span>) <span class="hljs-comment"># Cast a memoryview to a new format.</span> |
1738 |
| -<mview>.release() <span class="hljs-comment"># Releases the buffer.</span> |
| 1738 | +<mview> = <mview>.cast(<span class="hljs-string">'<typecode>'</span>) <span class="hljs-comment"># Casts a memoryview to a new format.</span> |
| 1739 | +<mview>.release() <span class="hljs-comment"># Releases the object's memory buffer.</span> |
1739 | 1740 | </code></pre></div>
|
1740 | 1741 |
|
1741 | 1742 |
|
|
1943 | 1944 | reader(adder(printer())) <span class="hljs-comment"># 100, 101, ..., 109</span>
|
1944 | 1945 | </code></pre></div>
|
1945 | 1946 |
|
| 1947 | +<p><br></p> |
1946 | 1948 | <div><h1 id="libraries">Libraries</h1><div><h2 id="progressbar"><a href="#progressbar" name="progressbar">#</a>Progress Bar</h2><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install tqdm</span>
|
1947 | 1949 | <span class="hljs-keyword">from</span> tqdm <span class="hljs-keyword">import</span> tqdm
|
1948 | 1950 | <span class="hljs-keyword">from</span> time <span class="hljs-keyword">import</span> sleep
|
|
0 commit comments