def byteswap ( data , word_size = 4 ) : return reduce ( lambda x , y : x + '' . join ( reversed ( y ) ) , chunks ( data , word_size ) , '' )
swapping bytes of data python
Swap the byte - ordering in a packet with N = 4 bytes per word
def byteswap(data, word_size=4):
    """ Swap the byte-ordering in a packet with N=4 bytes per word
    """
    return reduce(lambda x,y: x+''.join(reversed(y)), chunks(data, word_size), '')