diff options
author | Guido van Rossum <guido@python.org> | 1990-10-21 16:14:50 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1990-10-21 16:14:50 (GMT) |
commit | 5c124871b66e1af5aeebc6cba4d5320ef3620055 (patch) | |
tree | 534c6dff2b08984232fbd97f105d1e9171db2639 | |
parent | 9a1581cecaece4375ff6fd8643a21a6fc8ab5a49 (diff) | |
download | cpython-5c124871b66e1af5aeebc6cba4d5320ef3620055.zip cpython-5c124871b66e1af5aeebc6cba4d5320ef3620055.tar.gz cpython-5c124871b66e1af5aeebc6cba4d5320ef3620055.tar.bz2 |
Make readfile read the file in one fell swoop.
-rw-r--r-- | Lib/commands.py | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/Lib/commands.py b/Lib/commands.py index 145f5db..c96953c 100644 --- a/Lib/commands.py +++ b/Lib/commands.py @@ -4,6 +4,7 @@ import rand import posix +import stat import path @@ -40,14 +41,7 @@ def getstatusoutput(cmd): # Return a string containing a file's contents. # def readfile(fn): - fp = open(fn, 'r') - a = '' - n = 8096 - while 1: - b = fp.read(n) - if not b: break - a = a + b - return a + return open(fn, 'r').read(posix.stat(fn)[stat.ST_SIZE]) # Make command argument from directory and pathname (prefix space, add quotes). |