Skip to content

Commit 92a4c1a

Browse files
committed
Open
1 parent e060c2e commit 92a4c1a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ value = args.<name>
14291429

14301430
Open
14311431
----
1432-
**Opens a file and returns a corresponding file object or raises 'FileNotFoundError'.**
1432+
**Opens a file and returns a corresponding file object.**
14331433

14341434
```python
14351435
<file> = open('<path>', mode='r', encoding=None, newline=None)
@@ -1449,6 +1449,10 @@ Open
14491449
* **`'t'` - Text mode (default).**
14501450
* **`'b'` - Binary mode.**
14511451

1452+
### Exceptions
1453+
* **`'FileNotFoundError'` can be risen when reading with `'r'` or `'r+'`.**
1454+
* **`'FileExistsError'` can be risen when writing with `'x'`.**
1455+
14521456
### File
14531457
```python
14541458
<file>.seek(0) # Moves to the start of the file.

index.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ <h3 id="argparse">Argparse</h3>
13071307
<li><strong>Use <code class="python hljs"><span class="hljs-string">'type=FileType(&lt;mode&gt;)'</span></code> for files.</strong></li>
13081308
</ul>
13091309
<h2 id="open"><a href="#open" name="open">#</a>Open</h2>
1310-
<p><strong>Opens a file and returns a corresponding file object or raises 'FileNotFoundError'.</strong></p>
1310+
<p><strong>Opens a file and returns a corresponding file object.</strong></p>
13111311
<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>)
13121312
</code></pre>
13131313
<ul>
@@ -1327,6 +1327,11 @@ <h3 id="modes">Modes</h3>
13271327
<li><strong><code class="python hljs"><span class="hljs-string">'t'</span></code> - Text mode (default).</strong></li>
13281328
<li><strong><code class="python hljs"><span class="hljs-string">'b'</span></code> - Binary mode.</strong></li>
13291329
</ul>
1330+
<h3 id="exceptions-1">Exceptions</h3>
1331+
<ul>
1332+
<li><strong><code class="python hljs"><span class="hljs-string">'FileNotFoundError'</span></code> can be risen when reading with <code class="python hljs"><span class="hljs-string">'r'</span></code> or <code class="python hljs"><span class="hljs-string">'r+'</span></code>.</strong> </li>
1333+
<li><strong><code class="python hljs"><span class="hljs-string">'FileExistsError'</span></code> can be risen when writing with <code class="python hljs"><span class="hljs-string">'x'</span></code>.</strong></li>
1334+
</ul>
13301335
<h3 id="file">File</h3>
13311336
<pre><code class="python language-python hljs">&lt;file&gt;.seek(<span class="hljs-number">0</span>) <span class="hljs-comment"># Moves to the start of the file.</span>
13321337
&lt;file&gt;.seek(offset) <span class="hljs-comment"># Moves 'offset' chars/bytes from the start.</span>
@@ -1809,7 +1814,7 @@ <h2 id="logging"><a href="#logging" name="logging">#</a>Logging</h2>
18091814
<ul>
18101815
<li><strong>Levels: <code class="python hljs"><span class="hljs-string">'debug'</span></code>, <code class="python hljs"><span class="hljs-string">'info'</span></code>, <code class="python hljs"><span class="hljs-string">'success'</span></code>, <code class="python hljs"><span class="hljs-string">'warning'</span></code>, <code class="python hljs"><span class="hljs-string">'error'</span></code>, <code class="python hljs"><span class="hljs-string">'critical'</span></code>.</strong></li>
18111816
</ul>
1812-
<h3 id="exceptions-1">Exceptions</h3>
1817+
<h3 id="exceptions-2">Exceptions</h3>
18131818
<p><strong>Error description, stack trace and values of variables are appended automatically.</strong></p>
18141819
<pre><code class="python language-python hljs"><span class="hljs-keyword">try</span>:
18151820
...

0 commit comments

Comments
 (0)