<[EMAIL PROTECTED]> wrote 
> i have a long stream of data, represented in hexadecimal
> form. I need to split it in bytes (by 2 chars each). eg
> '00010203040506'... -> ['00', '01, '02' ...].

> So my question is: is there an inverse function of zip, or
> an easy way to split this long string in pairs (without
> indexing in cycle, nor regexpr.)?

I'm not quite sure what you mean by 'indexing in cycle' 
but you will need some kind of loop to extract this data
whether explicit or hidden inside a library function.

My guess is the simplest solution is to use list slicing 
and a list comprehension with a step size of 2. 
Something like:

bytes = [stream[start :start+2] for start in range(0,len(stream),2)]

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
     

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to