Skip to content

Commit 0b26977

Browse files
committed
Open
1 parent 60286b8 commit 0b26977

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,8 @@ Open
12811281
```python
12821282
<file>.seek(0) # Moves to the start of the file.
12831283
<file>.seek(offset) # Moves 'offset' chars/bytes from the start.
1284-
<file>.seek(offset, <anchor>) # Anchor: 0 start, 1 current pos., 2 end.
1284+
<file>.seek(0, 2) # Moves to the end of the file.
1285+
<bin_file>.seek(±offset, <anchor>) # Anchor: 0 start, 1 current pos., 2 end.
12851286
```
12861287

12871288
```python
@@ -1293,10 +1294,10 @@ Open
12931294

12941295
```python
12951296
<file>.write(<str/bytes>) # Writes a string or bytes object.
1296-
<file>.writelines(<list>) # Writes a list of strings or bytes objects.
1297+
<file>.writelines(<coll.>) # Writes a coll. of strings or bytes objects.
12971298
<file>.flush() # Flushes write buffer.
12981299
```
1299-
* **Methods do not add or strip trailing newlines.**
1300+
* **Methods do not add or strip trailing newlines, even writelines().**
13001301

13011302
### Read Text from File
13021303
```python

index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,19 +1162,20 @@ <h3 id="modes">Modes</h3>
11621162
<h3 id="file">File</h3>
11631163
<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>
11641164
&lt;file&gt;.seek(offset) <span class="hljs-comment"># Moves 'offset' chars/bytes from the start.</span>
1165-
&lt;file&gt;.seek(offset, &lt;anchor&gt;) <span class="hljs-comment"># Anchor: 0 start, 1 current pos., 2 end.</span>
1165+
&lt;file&gt;.seek(<span class="hljs-number">0</span>, <span class="hljs-number">2</span>) <span class="hljs-comment"># Moves to the end of the file.</span>
1166+
&lt;bin_file&gt;.seek(±offset, &lt;anchor&gt;) <span class="hljs-comment"># Anchor: 0 start, 1 current pos., 2 end.</span>
11661167
</code></pre>
11671168
<pre><code class="python language-python hljs">&lt;str/bytes&gt; = &lt;file&gt;.read(size=<span class="hljs-number">-1</span>) <span class="hljs-comment"># Reads 'size' chars/bytes or until EOF.</span>
11681169
&lt;str/bytes&gt; = &lt;file&gt;.readline() <span class="hljs-comment"># Returns a line.</span>
11691170
&lt;list&gt; = &lt;file&gt;.readlines() <span class="hljs-comment"># Returns a list of lines.</span>
11701171
&lt;str/bytes&gt; = next(&lt;file&gt;) <span class="hljs-comment"># Returns a line using buffer. Do not mix.</span>
11711172
</code></pre>
11721173
<pre><code class="python language-python hljs">&lt;file&gt;.write(&lt;str/bytes&gt;) <span class="hljs-comment"># Writes a string or bytes object.</span>
1173-
&lt;file&gt;.writelines(&lt;list&gt;) <span class="hljs-comment"># Writes a list of strings or bytes objects.</span>
1174+
&lt;file&gt;.writelines(&lt;coll.&gt;) <span class="hljs-comment"># Writes a coll. of strings or bytes objects.</span>
11741175
&lt;file&gt;.flush() <span class="hljs-comment"># Flushes write buffer.</span>
11751176
</code></pre>
11761177
<ul>
1177-
<li><strong>Methods do not add or strip trailing newlines.</strong></li>
1178+
<li><strong>Methods do not add or strip trailing newlines, even writelines().</strong></li>
11781179
</ul>
11791180
<h3 id="readtextfromfile">Read Text from File</h3>
11801181
<pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">read_file</span><span class="hljs-params">(filename)</span>:</span>

0 commit comments

Comments
 (0)