views:

174

answers:

2

Hi!

I'm translating some of my old Ruby scripts into Python and I have trouble finding a function in Python that belongs to Ruby: http://www.ruby-doc.org/core/classes/Array.src/M002222.html - which keeps the array in little endian byte order. Is there any Python module that can help me?

+4  A: 

Perhaps http://docs.python.org/library/struct.html does something similar.

+1  A: 

The array module of Python's standard library may offer somewhat-similar functionality (though it's definitely not an exact match). It does not force endianness (you can swap items' endianness with method byteswap) and does not intrinsically keep items as "a string" (you can convert back and forth with methods tostring and fromstring) but it may be worth looking at, depending on how you're using the Ruby pack function I guess.

Alex Martelli