diff options
author | Guido van Rossum <guido@python.org> | 2000-02-02 15:10:15 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-02-02 15:10:15 (GMT) |
commit | 4acc25bd392216c4f867a10ca8081e7c8a739676 (patch) | |
tree | db4976fa172404339b31aa7485a5316634e4c699 /Lib/StringIO.py | |
parent | 113e70efa2b932a3ad2662875114133a1edb600c (diff) | |
download | cpython-4acc25bd392216c4f867a10ca8081e7c8a739676.zip cpython-4acc25bd392216c4f867a10ca8081e7c8a739676.tar.gz cpython-4acc25bd392216c4f867a10ca8081e7c8a739676.tar.bz2 |
Mass patch by Ka-Ping Yee:
1. Comments at the beginning of the module, before
functions, and before classes have been turned
into docstrings.
2. Tabs are normalized to four spaces.
Also, removed the "remove" function from dircmp.py, which reimplements
list.remove() (it must have been very old).
Diffstat (limited to 'Lib/StringIO.py')
-rw-r--r-- | Lib/StringIO.py | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/Lib/StringIO.py b/Lib/StringIO.py index fc195b9..04ffec9 100644 --- a/Lib/StringIO.py +++ b/Lib/StringIO.py @@ -1,30 +1,30 @@ -# class StringIO implements file-like objects that read/write a -# string buffer (a.k.a. "memory files"). -# -# This implements (nearly) all stdio methods. -# -# f = StringIO() # ready for writing -# f = StringIO(buf) # ready for reading -# f.close() # explicitly release resources held -# flag = f.isatty() # always false -# pos = f.tell() # get current position -# f.seek(pos) # set current position -# f.seek(pos, mode) # mode 0: absolute; 1: relative; 2: relative to EOF -# buf = f.read() # read until EOF -# buf = f.read(n) # read up to n bytes -# buf = f.readline() # read until end of line ('\n') or EOF -# list = f.readlines()# list of f.readline() results until EOF -# f.write(buf) # write at current position -# f.writelines(list) # for line in list: f.write(line) -# f.getvalue() # return whole file's contents as a string -# -# Notes: -# - Using a real file is often faster (but less convenient). -# - fileno() is left unimplemented so that code which uses it triggers -# an exception early. -# - Seeking far beyond EOF and then writing will insert real null -# bytes that occupy space in the buffer. -# - There's a simple test set (see end of this file). +"""File-like objects that read from or write to a string buffer. + +This implements (nearly) all stdio methods. + +f = StringIO() # ready for writing +f = StringIO(buf) # ready for reading +f.close() # explicitly release resources held +flag = f.isatty() # always false +pos = f.tell() # get current position +f.seek(pos) # set current position +f.seek(pos, mode) # mode 0: absolute; 1: relative; 2: relative to EOF +buf = f.read() # read until EOF +buf = f.read(n) # read up to n bytes +buf = f.readline() # read until end of line ('\n') or EOF +list = f.readlines()# list of f.readline() results until EOF +f.write(buf) # write at current position +f.writelines(list) # for line in list: f.write(line) +f.getvalue() # return whole file's contents as a string + +Notes: +- Using a real file is often faster (but less convenient). +- fileno() is left unimplemented so that code which uses it triggers + an exception early. +- Seeking far beyond EOF and then writing will insert real null + bytes that occupy space in the buffer. +- There's a simple test set (see end of this file). +""" import string |