mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
__iter__(): New method so that StringIO's can participate in the
iterator protocol.
This commit is contained in:
parent
038d26410d
commit
bdefa0b3de
1 changed files with 3 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue