Message109117
Until this feature gets built into Python, you can use a Python-coded generator such as this one to accomplish the same effect:
def fileLineIter(inputFile,
inputNewline="\n",
outputNewline=None,
readSize=8192):
"""Like the normal file iter but you can set what string indicates newline.
The newline string can be arbitrarily long; it need not be restricted to a
single character. You can also set the read size and control whether or not
the newline string is left on the end of the iterated lines. Setting
newline to '\0' is particularly good for use with an input file created with
something like "os.popen('find -print0')".
"""
if outputNewline is None: outputNewline = inputNewline
partialLine = ''
while True:
charsJustRead = inputFile.read(readSize)
if not charsJustRead: break
partialLine += charsJustRead
lines = partialLine.split(inputNewline)
partialLine = lines.pop()
for line in lines: yield line + outputNewline
if partialLine: yield partialLine |
|
Date |
User |
Action |
Args |
2010-07-02 17:31:20 | Douglas.Alan | set | recipients:
+ Douglas.Alan, georg.brandl, rhettinger, facundobatista, ncoghlan, pitrou, benjamin.peterson, nessus42, eric.araujo, ralph.corderoy, r.david.murray |
2010-07-02 17:31:18 | Douglas.Alan | set | messageid: <1278091878.84.0.416741249003.issue1152248@psf.upfronthosting.co.za> |
2010-07-02 17:31:17 | Douglas.Alan | link | issue1152248 messages |
2010-07-02 17:31:16 | Douglas.Alan | create | |
|