From ffd0c6b4c3fa56fb3fcfe58e82b90fa9f958e147 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Thu, 16 Jul 2009 16:14:38 +0200 Subject: [PATCH] [entropy.tools] add new function split_indexable_into_chunks --- libraries/entropy/tools.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libraries/entropy/tools.py b/libraries/entropy/tools.py index 2aa8e908b..285681875 100644 --- a/libraries/entropy/tools.py +++ b/libraries/entropy/tools.py @@ -453,6 +453,19 @@ def get_random_number(): random.seed() return random.randint(10000,99999) +def split_indexable_into_chunks(mystr, chunk_len): + chunks = [] + my = mystr[:] + mylen = len(my) + mycount = 0 + while mylen: + chunk = my[:chunk_len] + chunks.append(chunk) + my_chunk_len = len(chunk) + my = my[my_chunk_len:] + mylen -= my_chunk_len + return chunks + def countdown(secs=5, what="Counting...", back = False): if secs: if back: