]> granicus.if.org Git - python/commitdiff
__iter__(): New method so that StringIO's can participate in the
authorBarry Warsaw <barry@python.org>
Sat, 22 Sep 2001 04:34:54 +0000 (04:34 +0000)
committerBarry Warsaw <barry@python.org>
Sat, 22 Sep 2001 04:34:54 +0000 (04:34 +0000)
iterator protocol.

Lib/StringIO.py

index 2aef3c329e166504892245c638fbd4ba9b3004cf..cb7313d42a92c9de496eaef1a812b78be7a5d61f 100644 (file)
@@ -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