Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
eb33b3fd
Commit
eb33b3fd
authored
Feb 19, 1991
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added readfile() and readopenfile() functions.
parent
da1b5d1e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
4 deletions
+46
-4
Lib/lib-old/util.py
Lib/lib-old/util.py
+23
-2
Lib/util.py
Lib/util.py
+23
-2
No files found.
Lib/lib-old/util.py
View file @
eb33b3fd
# Module 'util' -- some useful functions that dont fit elsewhere
# Module 'util' -- some useful functions that don
'
t fit elsewhere
# Remove an item from a list at most once
# Remove an item from a list.
# No complaints if it isn't in the list at all.
# If it occurs more than once, remove the first occurrence.
#
#
def
remove
(
item
,
list
):
def
remove
(
item
,
list
):
for
i
in
range
(
len
(
list
)):
for
i
in
range
(
len
(
list
)):
if
list
[
i
]
=
item
:
if
list
[
i
]
=
item
:
del
list
[
i
]
del
list
[
i
]
break
break
# Return a string containing a file's contents.
#
def
readfile
(
fn
):
return
readopenfile
(
open
(
fn
,
'r'
))
# Read an open file until EOF.
#
def
readopenfile
(
fp
):
BUFSIZE
=
512
*
8
data
=
''
while
1
:
buf
=
fp
.
read
(
BUFSIZE
)
if
not
buf
:
break
data
=
data
+
buf
return
data
Lib/util.py
View file @
eb33b3fd
# Module 'util' -- some useful functions that dont fit elsewhere
# Module 'util' -- some useful functions that don
'
t fit elsewhere
# Remove an item from a list at most once
# Remove an item from a list.
# No complaints if it isn't in the list at all.
# If it occurs more than once, remove the first occurrence.
#
#
def
remove
(
item
,
list
):
def
remove
(
item
,
list
):
for
i
in
range
(
len
(
list
)):
for
i
in
range
(
len
(
list
)):
if
list
[
i
]
=
item
:
if
list
[
i
]
=
item
:
del
list
[
i
]
del
list
[
i
]
break
break
# Return a string containing a file's contents.
#
def
readfile
(
fn
):
return
readopenfile
(
open
(
fn
,
'r'
))
# Read an open file until EOF.
#
def
readopenfile
(
fp
):
BUFSIZE
=
512
*
8
data
=
''
while
1
:
buf
=
fp
.
read
(
BUFSIZE
)
if
not
buf
:
break
data
=
data
+
buf
return
data
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment