summaryrefslogtreecommitdiffstats
path: root/Lib/StringIO.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-09-22 04:34:54 (GMT)
committerBarry Warsaw <barry@python.org>2001-09-22 04:34:54 (GMT)
commitbdefa0b3dec131cdd11bdb4ba9338fc94f53aa7f (patch)
tree4c5d533291148cd102a1f12d15d70439c0acdf3a /Lib/StringIO.py
parent038d26410dba1ab0a84804ff52c732e243df6f6a (diff)
downloadcpython-bdefa0b3dec131cdd11bdb4ba9338fc94f53aa7f.zip
cpython-bdefa0b3dec131cdd11bdb4ba9338fc94f53aa7f.tar.gz
cpython-bdefa0b3dec131cdd11bdb4ba9338fc94f53aa7f.tar.bz2
__iter__(): New method so that StringIO's can participate in the
iterator protocol.
Diffstat (limited to 'Lib/StringIO.py')
-rw-r--r--Lib/StringIO.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/StringIO.py b/Lib/StringIO.py
index 2aef3c3..cb7313d 100644
--- a/Lib/StringIO.py
+++ b/Lib/StringIO.py
@@ -45,6 +45,9 @@ class StringIO:
self.closed = 0
self.softspace = 0
+ def __iter__(self):
+ return iter(self.readline, '')
+
def close(self):
if not self.closed:
self.closed = 1