Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c12487

Browse files
committed
Make readfile read the file in one fell swoop.
1 parent 9a1581c commit 5c12487

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

Lib/commands.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import rand
66
import posix
7+
import stat
78
import path
89

910

@@ -40,14 +41,7 @@ def getstatusoutput(cmd):
4041
# Return a string containing a file's contents.
4142
#
4243
def readfile(fn):
43-
fp = open(fn, 'r')
44-
a = ''
45-
n = 8096
46-
while 1:
47-
b = fp.read(n)
48-
if not b: break
49-
a = a + b
50-
return a
44+
return open(fn, 'r').read(posix.stat(fn)[stat.ST_SIZE])
5145

5246

5347
# Make command argument from directory and pathname (prefix space, add quotes).

0 commit comments

Comments
 (0)