Let’s say I’d like to split some data into 60-character parts and store them in a hash. I’ve got the following solution, but it seems a bit dirty to me: (because of iteration and constant reassigning)
i = 0
while signature != '':
header_hash['Some-Authorization-' + i] = signature[:60]
signature = signature[60:]
i += 1
Can you come up with a better way of handling this?
Although fairly similar to how to evenly split a list into chunks I believe this to still be a valid problem, but will contain part of the answer to that previous question:
This would be my answer, Looking over the
itertoolsfunctions provided I suspect rejoining them after the grouping would negate any benefit from using itertools.