imageguy: > I receive the byte string with the following sequence 'bgrbgrbgrbgr' > and I would like to convert this to 'rbgrbgrbgrbg' > FWIW, the string is created using ctypes.create_string_buffer function
MRAB: > >>> a.tostring() > '210543876' That's not the required 'rbgrbgrbgrbg', but you are close to a correct solution: >>> from array import array >>> s = 'bgrbgrbgrbgr' >>> a = array("B", s) # uppercase B >>> a[0::3], a[1::3], a[2::3] = a[2::3], a[0::3], a[1::3] >>> a.tostring() 'rbgrbgrbgrbg' Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list