Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #58826

Re: chunking a long string?

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: chunking a long string?
Date 2013-11-08 17:52 +0000
References <9258483E-76BD-4D96-8C46-7262A95E3ED4@panix.com>
Newsgroups comp.lang.python
Message-ID <mailman.2234.1383933167.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 08/11/2013 17:48, Roy Smith wrote:
> I have a long string (several Mbytes).  I want to iterate over it in manageable chunks (say, 1 kbyte each).  For (a small) example, if I started with "this is a very long string", and I wanted 10 character chunks, I should get:
>
> "this is a"
> "very long"
> "string"
>
> This seems like something itertools would do, but I don't see anything.  Is there something, or do I just need to loop and slice (and worry about getting all the edge conditions right) myself?
>
> ---
> Roy Smith
> roy@panix.com
>

Any good to you http://pythonhosted.org/more-itertools/api.html ?

-- 
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: chunking a long string? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-08 17:52 +0000

csiph-web