> I have a long string (several Mbytes).  I want to iterate over it in 
> manageable chunks (say, 1 kbyte each).

You don't mention if the string is in memory or on disk. If it's in memory:

>>> for i in range(0, len(s), 10):
...   print repr(s[i:i+10])
...
'this is a '
'very long '
'string'

If your string is on disk, just loop over an open file object, reading
your chunk size every pass of the loop.

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to