Skip to content

Commit 9ae5500

Browse files
committed
Small fixes
1 parent 40fdfd3 commit 9ae5500

File tree

3 files changed

+62
-62
lines changed

3 files changed

+62
-62
lines changed

README.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,13 +1493,13 @@ value = args.<name>
14931493

14941494
Open
14951495
----
1496-
**Opens a file and returns a corresponding file object.**
1496+
**Opens the file and returns a corresponding file object.**
14971497

14981498
```python
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 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 the 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
@@ -1570,8 +1570,8 @@ from glob import glob
15701570
```
15711571

15721572
```python
1573-
<list> = listdir('<path>') # List of filenames located at path.
1574-
<list> = glob('<pattern>') # Filenames matching the wildcard pattern.
1573+
<list> = listdir('<path>') # List of filenames located at path.
1574+
<list> = glob('<pattern>') # Filenames matching the wildcard pattern.
15751575
```
15761576

15771577
### Pathlib
@@ -1592,22 +1592,22 @@ cwd = Path()
15921592
```
15931593

15941594
```python
1595-
<iter> = <Path>.iterdir() # Returns dir contents as Path objects.
1596-
<iter> = <Path>.glob('<pattern>') # Returns Paths matching the wildcard pattern.
1595+
<iter> = <Path>.iterdir() # Returns dir contents as Path objects.
1596+
<iter> = <Path>.glob('<pattern>') # Returns Paths matching the wildcard pattern.
15971597
```
15981598

15991599
```python
1600-
<str> = str(<Path>) # Path as a string.
1601-
<str> = <Path>.name # Final component.
1602-
<str> = <Path>.stem # Final component without extension.
1603-
<str> = <Path>.suffix # Final component's extension.
1604-
<tup.> = <Path>.parts # All components as strings.
1600+
<str> = str(<Path>) # Path as a string.
1601+
<str> = <Path>.name # Final component.
1602+
<str> = <Path>.stem # Final component without extension.
1603+
<str> = <Path>.suffix # Final component's extension.
1604+
<tup.> = <Path>.parts # All components as strings.
16051605
```
16061606

16071607
```python
1608-
<Path> = <Path>.resolve() # Returns absolute path without symlinks.
1609-
<Path> = <Path>.parent # Returns path without final component.
1610-
<file> = open(<Path>) # Opens the file and returns a file object.
1608+
<Path> = <Path>.resolve() # Returns absolute path without symlinks.
1609+
<Path> = <Path>.parent # Returns path without final component.
1610+
<file> = open(<Path>) # Opens the file and returns a file object.
16111611
```
16121612

16131613

@@ -1622,29 +1622,29 @@ import os, shutil
16221622
```
16231623

16241624
```python
1625-
os.chdir(<path>) # Changes current working directory.
1626-
os.mkdir(<path>, mode=0o777) # Creates a directory.
1625+
os.chdir(<path>) # Changes current working directory.
1626+
os.mkdir(<path>, mode=0o777) # Creates a directory.
16271627
```
16281628

16291629
```python
1630-
os.rename(from, to) # Renames the file or directory.
1631-
os.replace(from, to) # Same, but overwrites 'to' if it exists.
1630+
os.rename(from, to) # Renames the file or directory.
1631+
os.replace(from, to) # Same, but overwrites 'to' if it exists.
16321632
```
16331633

16341634
```python
1635-
os.remove(<path>) # Deletes the file.
1636-
os.rmdir(<path>) # Deletes empty directory.
1637-
shutil.rmtree(<path>) # Deletes the entire directory tree.
1635+
os.remove(<path>) # Deletes the file.
1636+
os.rmdir(<path>) # Deletes empty directory.
1637+
shutil.rmtree(<path>) # Deletes the entire directory tree.
16381638
```
16391639

16401640
```python
1641-
shutil.copy(from, to) # Copies the file.
1642-
shutil.copytree(from, to) # Copies the entire directory tree.
1641+
shutil.copy(from, to) # Copies the file.
1642+
shutil.copytree(from, to) # Copies the entire directory tree.
16431643
```
16441644

16451645
```python
1646-
<str> = os.getcwd() # Returns the current working directory.
1647-
<iter> = os.scandir(path='.') # Returns os.DirEntry objects located at path.
1646+
<str> = os.getcwd() # Returns the current working directory.
1647+
<iter> = os.scandir(path='.') # Returns os.DirEntry objects located at path.
16481648
```
16491649

16501650
#### DirEntry:
@@ -1654,13 +1654,13 @@ shutil.copytree(from, to) # Copies the entire directory tree.
16541654
```
16551655

16561656
```python
1657-
<str> = <DirEntry>.path # Path as a string.
1658-
<str> = <DirEntry>.name # Final component.
1657+
<str> = <DirEntry>.path # Path as a string.
1658+
<str> = <DirEntry>.name # Final component.
16591659
```
16601660

16611661
```python
1662-
<Path> = Path(<DirEntry>) # Path object.
1663-
<file> = open(<DirEntry>) # File object.
1662+
<Path> = Path(<DirEntry>) # Path object.
1663+
<file> = open(<DirEntry>) # File object.
16641664
```
16651665

16661666
### Shell Commands

index.html

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,13 +1381,13 @@
13811381
<li><strong>Use <code class="python hljs"><span class="hljs-string">'default=&lt;el&gt;'</span></code> to set the default value.</strong></li>
13821382
<li><strong>Use <code class="python hljs"><span class="hljs-string">'type=FileType(&lt;mode&gt;)'</span></code> for files.</strong></li>
13831383
</ul>
1384-
<div><h2 id="open"><a href="#open" name="open">#</a>Open</h2><p><strong>Opens a file and returns a corresponding file object.</strong></p><pre><code class="python language-python hljs">&lt;file&gt; = open(<span class="hljs-string">'&lt;path&gt;'</span>, mode=<span class="hljs-string">'r'</span>, encoding=<span class="hljs-keyword">None</span>, newline=<span class="hljs-keyword">None</span>)
1384+
<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(<span class="hljs-string">'&lt;path&gt;'</span>, mode=<span class="hljs-string">'r'</span>, encoding=<span class="hljs-keyword">None</span>, newline=<span class="hljs-keyword">None</span>)
13851385
</code></pre></div>
13861386

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 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 the 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>
@@ -1445,8 +1445,8 @@
14451445
&lt;bool&gt; = path.isfile(<span class="hljs-string">'&lt;path&gt;'</span>)
14461446
&lt;bool&gt; = path.isdir(<span class="hljs-string">'&lt;path&gt;'</span>)
14471447
</code></pre>
1448-
<pre><code class="python language-python hljs">&lt;list&gt; = listdir(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># List of filenames located at path.</span>
1449-
&lt;list&gt; = glob(<span class="hljs-string">'&lt;pattern&gt;'</span>) <span class="hljs-comment"># Filenames matching the wildcard pattern.</span>
1448+
<pre><code class="python language-python hljs">&lt;list&gt; = listdir(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-comment"># List of filenames located at path.</span>
1449+
&lt;list&gt; = glob(<span class="hljs-string">'&lt;pattern&gt;'</span>) <span class="hljs-comment"># Filenames matching the wildcard pattern.</span>
14501450
</code></pre>
14511451
<div><h3 id="pathlib">Pathlib</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> pathlib <span class="hljs-keyword">import</span> Path
14521452
</code></pre></div>
@@ -1459,18 +1459,18 @@
14591459
&lt;bool&gt; = &lt;Path&gt;.is_file()
14601460
&lt;bool&gt; = &lt;Path&gt;.is_dir()
14611461
</code></pre>
1462-
<pre><code class="python language-python hljs">&lt;iter&gt; = &lt;Path&gt;.iterdir() <span class="hljs-comment"># Returns dir contents as Path objects.</span>
1463-
&lt;iter&gt; = &lt;Path&gt;.glob(<span class="hljs-string">'&lt;pattern&gt;'</span>) <span class="hljs-comment"># Returns Paths matching the wildcard pattern.</span>
1462+
<pre><code class="python language-python hljs">&lt;iter&gt; = &lt;Path&gt;.iterdir() <span class="hljs-comment"># Returns dir contents as Path objects.</span>
1463+
&lt;iter&gt; = &lt;Path&gt;.glob(<span class="hljs-string">'&lt;pattern&gt;'</span>) <span class="hljs-comment"># Returns Paths matching the wildcard pattern.</span>
14641464
</code></pre>
1465-
<pre><code class="python language-python hljs">&lt;str&gt; = str(&lt;Path&gt;) <span class="hljs-comment"># Path as a string.</span>
1466-
&lt;str&gt; = &lt;Path&gt;.name <span class="hljs-comment"># Final component.</span>
1467-
&lt;str&gt; = &lt;Path&gt;.stem <span class="hljs-comment"># Final component without extension.</span>
1468-
&lt;str&gt; = &lt;Path&gt;.suffix <span class="hljs-comment"># Final component's extension.</span>
1469-
&lt;tup.&gt; = &lt;Path&gt;.parts <span class="hljs-comment"># All components as strings.</span>
1465+
<pre><code class="python language-python hljs">&lt;str&gt; = str(&lt;Path&gt;) <span class="hljs-comment"># Path as a string.</span>
1466+
&lt;str&gt; = &lt;Path&gt;.name <span class="hljs-comment"># Final component.</span>
1467+
&lt;str&gt; = &lt;Path&gt;.stem <span class="hljs-comment"># Final component without extension.</span>
1468+
&lt;str&gt; = &lt;Path&gt;.suffix <span class="hljs-comment"># Final component's extension.</span>
1469+
&lt;tup.&gt; = &lt;Path&gt;.parts <span class="hljs-comment"># All components as strings.</span>
14701470
</code></pre>
1471-
<pre><code class="python language-python hljs">&lt;Path&gt; = &lt;Path&gt;.resolve() <span class="hljs-comment"># Returns absolute path without symlinks.</span>
1472-
&lt;Path&gt; = &lt;Path&gt;.parent <span class="hljs-comment"># Returns path without final component.</span>
1473-
&lt;file&gt; = open(&lt;Path&gt;) <span class="hljs-comment"># Opens the file and returns a file object.</span>
1471+
<pre><code class="python language-python hljs">&lt;Path&gt; = &lt;Path&gt;.resolve() <span class="hljs-comment"># Returns absolute path without symlinks.</span>
1472+
&lt;Path&gt; = &lt;Path&gt;.parent <span class="hljs-comment"># Returns path without final component.</span>
1473+
&lt;file&gt; = open(&lt;Path&gt;) <span class="hljs-comment"># Opens the file and returns a file object.</span>
14741474
</code></pre>
14751475
<div><h2 id="oscommands"><a href="#oscommands" name="oscommands">#</a>OS Commands</h2><div><h3 id="filesanddirectories">Files and Directories</h3><ul>
14761476
<li><strong>Paths can be either strings, Paths, or DirEntry objects.</strong></li>
@@ -1480,31 +1480,31 @@
14801480

14811481

14821482

1483-
<pre><code class="python language-python hljs">os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes current working directory.</span>
1484-
os.mkdir(&lt;path&gt;, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates a directory.</span>
1483+
<pre><code class="python language-python hljs">os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes current working directory.</span>
1484+
os.mkdir(&lt;path&gt;, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates a directory.</span>
14851485
</code></pre>
1486-
<pre><code class="python language-python hljs">os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>
1487-
os.replace(from, to) <span class="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
1486+
<pre><code class="python language-python hljs">os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>
1487+
os.replace(from, to) <span class="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
14881488
</code></pre>
1489-
<pre><code class="python language-python hljs">os.remove(&lt;path&gt;) <span class="hljs-comment"># Deletes the file.</span>
1490-
os.rmdir(&lt;path&gt;) <span class="hljs-comment"># Deletes empty directory.</span>
1491-
shutil.rmtree(&lt;path&gt;) <span class="hljs-comment"># Deletes the entire directory tree.</span>
1489+
<pre><code class="python language-python hljs">os.remove(&lt;path&gt;) <span class="hljs-comment"># Deletes the file.</span>
1490+
os.rmdir(&lt;path&gt;) <span class="hljs-comment"># Deletes empty directory.</span>
1491+
shutil.rmtree(&lt;path&gt;) <span class="hljs-comment"># Deletes the entire directory tree.</span>
14921492
</code></pre>
1493-
<pre><code class="python language-python hljs">shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>
1494-
shutil.copytree(from, to) <span class="hljs-comment"># Copies the entire directory tree.</span>
1493+
<pre><code class="python language-python hljs">shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>
1494+
shutil.copytree(from, to) <span class="hljs-comment"># Copies the entire directory tree.</span>
14951495
</code></pre>
1496-
<pre><code class="python language-python hljs">&lt;str&gt; = os.getcwd() <span class="hljs-comment"># Returns the current working directory.</span>
1497-
&lt;iter&gt; = os.scandir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns os.DirEntry objects located at path.</span>
1496+
<pre><code class="python language-python hljs">&lt;str&gt; = os.getcwd() <span class="hljs-comment"># Returns the current working directory.</span>
1497+
&lt;iter&gt; = os.scandir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns os.DirEntry objects located at path.</span>
14981498
</code></pre>
14991499
<div><h4 id="direntry">DirEntry:</h4><pre><code class="python language-python hljs">&lt;bool&gt; = &lt;DirEntry&gt;.is_file()
15001500
&lt;bool&gt; = &lt;DirEntry&gt;.is_dir()
15011501
</code></pre></div>
15021502

1503-
<pre><code class="python language-python hljs">&lt;str&gt; = &lt;DirEntry&gt;.path <span class="hljs-comment"># Path as a string.</span>
1504-
&lt;str&gt; = &lt;DirEntry&gt;.name <span class="hljs-comment"># Final component.</span>
1503+
<pre><code class="python language-python hljs">&lt;str&gt; = &lt;DirEntry&gt;.path <span class="hljs-comment"># Path as a string.</span>
1504+
&lt;str&gt; = &lt;DirEntry&gt;.name <span class="hljs-comment"># Final component.</span>
15051505
</code></pre>
1506-
<pre><code class="python language-python hljs">&lt;Path&gt; = Path(&lt;DirEntry&gt;) <span class="hljs-comment"># Path object.</span>
1507-
&lt;file&gt; = open(&lt;DirEntry&gt;) <span class="hljs-comment"># File object.</span>
1506+
<pre><code class="python language-python hljs">&lt;Path&gt; = Path(&lt;DirEntry&gt;) <span class="hljs-comment"># Path object.</span>
1507+
&lt;file&gt; = open(&lt;DirEntry&gt;) <span class="hljs-comment"># File object.</span>
15081508
</code></pre>
15091509
<div><h3 id="shellcommands">Shell Commands</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> os
15101510
&lt;str&gt; = os.popen(<span class="hljs-string">'&lt;shell_command&gt;'</span>).read()

parse.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ const DIAGRAM_7_B =
195195
'┗━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n';
196196

197197
const OS_RENAME =
198-
'os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>\n' +
199-
'os.replace(from, to) <span class="hljs-comment"># Same, but overwrites \'to\' if it exists.</span>\n';
198+
'os.rename(from, to) <span class="hljs-comment"># Renames the file or directory.</span>\n' +
199+
'os.replace(from, to) <span class="hljs-comment"># Same, but overwrites \'to\' if it exists.</span>\n';
200200

201201
const SHUTIL_COPY =
202-
'shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>\n' +
203-
'shutil.copytree(from, to) <span class="hljs-comment"># Copies the entire directory tree.</span>\n';
202+
'shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>\n' +
203+
'shutil.copytree(from, to) <span class="hljs-comment"># Copies the entire directory tree.</span>\n';
204204

205205
const EVAL =
206206
'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> ast <span class="hljs-keyword">import</span> literal_eval\n' +

0 commit comments

Comments
 (0)