Equivalent for pop on strings
you can convert the string to a list. list(string)
and pop it, or you could iterate in chunks slicing the list []
or you can slice the string as is and iterate in chunks
You can wrap the string in a StringIO
or BytesIO
and pretend it's a file. That should be pretty fast.
from cStringIO import StringIO
# or, in Py3/Py2.6+:
#from io import BytesIO, StringIO
s = StringIO(large_string)
while True:
chunk = s.read(200)
if len(chunk) > 0:
process(chunk)
if len(chunk) < 200:
break