From bdefa0b3dec131cdd11bdb4ba9338fc94f53aa7f Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Sat, 22 Sep 2001 04:34:54 +0000 Subject: __iter__(): New method so that StringIO's can participate in the iterator protocol. --- Lib/StringIO.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Lib/StringIO.py') diff --git a/Lib/StringIO.py b/Lib/StringIO.py index 2aef3c329e1..cb7313d42a9 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 -- cgit v1.2.3