File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # Module 'util' -- some useful functions that dont fit elsewhere
1+ # Module 'util' -- some useful functions that don't fit elsewhere
22
3- # Remove an item from a list at most once
3+
4+ # Remove an item from a list.
5+ # No complaints if it isn't in the list at all.
6+ # If it occurs more than once, remove the first occurrence.
47#
58def remove (item , list ):
69 for i in range (len (list )):
710 if list [i ] = item :
811 del list [i ]
912 break
13+
14+
15+ # Return a string containing a file's contents.
16+ #
17+ def readfile (fn ):
18+ return readopenfile (open (fn , 'r' ))
19+
20+
21+ # Read an open file until EOF.
22+ #
23+ 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
Original file line number Diff line number Diff line change 1- # Module 'util' -- some useful functions that dont fit elsewhere
1+ # Module 'util' -- some useful functions that don't fit elsewhere
22
3- # Remove an item from a list at most once
3+
4+ # Remove an item from a list.
5+ # No complaints if it isn't in the list at all.
6+ # If it occurs more than once, remove the first occurrence.
47#
58def remove (item , list ):
69 for i in range (len (list )):
710 if list [i ] = item :
811 del list [i ]
912 break
13+
14+
15+ # Return a string containing a file's contents.
16+ #
17+ def readfile (fn ):
18+ return readopenfile (open (fn , 'r' ))
19+
20+
21+ # Read an open file until EOF.
22+ #
23+ 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
You can’t perform that action at this time.
0 commit comments