Kaydet (Commit) c1265bd9 authored tarafından Guido van Rossum's avatar Guido van Rossum

Make StringIO its own iterator, similar to real files.

(This should also be done to cStringIO.)
üst 5b8132ff
......@@ -59,7 +59,15 @@ class StringIO:
self.softspace = 0
def __iter__(self):
return iter(self.readline, '')
return self
def next(self):
if self.closed:
raise StopIteration
r = self.readline()
if not r:
raise StopIteration
return r
def close(self):
"""Free the memory buffer.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment