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

Skip to content

Commit d9d2c82

Browse files
committed
This is no longer needed, since all these functions are now built-in
(with different interfaces). Change the module definition to call the built-in functions, for compatibility.
1 parent 6179fe6 commit d9d2c82

2 files changed

Lines changed: 12 additions & 22 deletions

File tree

Lib/lib-old/util.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# Module 'util' -- some useful functions that don't fit elsewhere
22

3+
# NB: These are now built-in functions, but this module is provided
4+
# for compatibility. Don't use in new programs unless you need backward
5+
# compatibility (with old interpreters).
6+
37

48
# Remove an item from a list.
59
# No complaints if it isn't in the list at all.
610
# If it occurs more than once, remove the first occurrence.
711
#
812
def remove(item, list):
9-
for i in range(len(list)):
10-
if list[i] = item:
11-
del list[i]
12-
break
13+
if item in list: list.remove(item)
1314

1415

1516
# Return a string containing a file's contents.
@@ -21,10 +22,4 @@ def readfile(fn):
2122
# Read an open file until EOF.
2223
#
2324
def readopenfile(fp):
24-
BUFSIZE = 512*8
25-
data = ''
26-
while 1:
27-
buf = fp.read(BUFSIZE)
28-
if not buf: break
29-
data = data + buf
30-
return data
25+
return fp.read()

Lib/util.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# Module 'util' -- some useful functions that don't fit elsewhere
22

3+
# NB: These are now built-in functions, but this module is provided
4+
# for compatibility. Don't use in new programs unless you need backward
5+
# compatibility (with old interpreters).
6+
37

48
# Remove an item from a list.
59
# No complaints if it isn't in the list at all.
610
# If it occurs more than once, remove the first occurrence.
711
#
812
def remove(item, list):
9-
for i in range(len(list)):
10-
if list[i] = item:
11-
del list[i]
12-
break
13+
if item in list: list.remove(item)
1314

1415

1516
# Return a string containing a file's contents.
@@ -21,10 +22,4 @@ def readfile(fn):
2122
# Read an open file until EOF.
2223
#
2324
def readopenfile(fp):
24-
BUFSIZE = 512*8
25-
data = ''
26-
while 1:
27-
buf = fp.read(BUFSIZE)
28-
if not buf: break
29-
data = data + buf
30-
return data
25+
return fp.read()

0 commit comments

Comments
 (0)