detect endianness of a binary with python
Michael Torrie
torriem at gmail.com
Wed Jul 21 10:44:57 EDT 2010
On 07/21/2010 08:02 AM, Grant Edwards wrote:
> On 2010-07-21, Holger brunck <holger.brunck at keymile.com> wrote:
>
>> I use python 2.5 and I am looking for a possibility to determine a
>> file type. Especially the endianness of a file is needed for me. Is
>> there a way to detect this easily in python?
>
> Only if you already know what's going to be in the file.
>
>> Something like the "file" utility for linux would be very helpfull.
>>
>> Any help is appreciated.
>
> You're going to have to describe in detail what's in the file before
> anybody can help.
There is a python module called "magic" that uses the same engine as
file to determine a file type. It's part of the "find" source code:
http://www.darwinsys.com/file/
On Fedora I can just yum install python-magic to get it.
More information about the Python-list
mailing list