From 0b26977a8f535597e1e8a241b75dd3a0f64373b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 1 Jul 2019 02:51:09 +0200 Subject: [PATCH] Open --- README.md | 7 ++++--- index.html | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1bf2848..abd947b 100644 --- a/README.md +++ b/README.md @@ -1281,7 +1281,8 @@ Open ```python .seek(0) # Moves to the start of the file. .seek(offset) # Moves 'offset' chars/bytes from the start. -.seek(offset, ) # Anchor: 0 start, 1 current pos., 2 end. +.seek(0, 2) # Moves to the end of the file. +.seek(±offset, ) # Anchor: 0 start, 1 current pos., 2 end. ``` ```python @@ -1293,10 +1294,10 @@ Open ```python .write() # Writes a string or bytes object. -.writelines() # Writes a list of strings or bytes objects. +.writelines() # Writes a coll. of strings or bytes objects. .flush() # Flushes write buffer. ``` -* **Methods do not add or strip trailing newlines.** +* **Methods do not add or strip trailing newlines, even writelines().** ### Read Text from File ```python diff --git a/index.html b/index.html index 816b2ac..81ac3b5 100644 --- a/index.html +++ b/index.html @@ -1162,7 +1162,8 @@ value = args.<name>

File

<file>.seek(0)                      # Moves to the start of the file.
 <file>.seek(offset)                 # Moves 'offset' chars/bytes from the start.
-<file>.seek(offset, <anchor>)       # Anchor: 0 start, 1 current pos., 2 end.
+<file>.seek(0, 2)                   # Moves to the end of the file.
+<bin_file>.seek(±offset, <anchor>)  # Anchor: 0 start, 1 current pos., 2 end.
 
<str/bytes> = <file>.read(size=-1)  # Reads 'size' chars/bytes or until EOF.
 <str/bytes> = <file>.readline()     # Returns a line.
@@ -1170,11 +1171,11 @@ value = args.<name>
 <str/bytes> = next(<file>)          # Returns a line using buffer. Do not mix.
 
<file>.write(<str/bytes>)           # Writes a string or bytes object.
-<file>.writelines(<list>)           # Writes a list of strings or bytes objects.
+<file>.writelines(<coll.>)          # Writes a coll. of strings or bytes objects.
 <file>.flush()                      # Flushes write buffer.
 
    -
  • Methods do not add or strip trailing newlines.
  • +
  • Methods do not add or strip trailing newlines, even writelines().

Read Text from File

def read_file(filename):