Moving from perl to python: questions
Nathan Clegg
nathan at islanddata.com
Wed Feb 16 11:47:01 EST 2000
On 16-Feb-2000 David R. Favor wrote:
> 2) How to implement a no-frills file slurp() function
import string
def slurp(filename):
print filename
try:
f = open(filename, 'r')
# catch whichever exceptions you fancy, here
# rstrip will strip all whitespace off the right side,
# much like chomp
lines = map(string.rstrip, f.readlines())
f.close
return lines
----------------------------------
Nathan Clegg
nathan at islanddata.com
More information about the Python-list
mailing list