From: Barry Warsaw Date: Sat, 22 Sep 2001 04:34:54 +0000 (+0000) Subject: __iter__(): New method so that StringIO's can participate in the X-Git-Tag: v2.2.1c1~1682 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bdefa0b3dec131cdd11bdb4ba9338fc94f53aa7f;p=python __iter__(): New method so that StringIO's can participate in the iterator protocol. --- diff --git a/Lib/StringIO.py b/Lib/StringIO.py index 2aef3c329e..cb7313d42a 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