Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > detect endianness of a binary with python

Reply
Thread Tools

detect endianness of a binary with python

 
 
Holger brunck
Guest
Posts: n/a
 
      07-21-2010
Hi all,
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? Something like the "file" utility for linux would be very
helpfull.

Any help is appreciated.

Best regards
Holger Brunck

 
Reply With Quote
 
 
 
 
Grant Edwards
Guest
Posts: n/a
 
      07-21-2010
On 2010-07-21, Holger brunck <(E-Mail Removed)> 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.

--
Grant Edwards grant.b.edwards Yow! A shapely CATHOLIC
at SCHOOLGIRL is FIDGETING
gmail.com inside my costume..
 
Reply With Quote
 
 
 
 
Michael Torrie
Guest
Posts: n/a
 
      07-21-2010
On 07/21/2010 08:02 AM, Grant Edwards wrote:
> On 2010-07-21, Holger brunck <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: detect endianness of a binary with python Thomas Jollans Python 1 07-22-2010 02:31 AM
Endianness and streams kelvSYC C++ 8 06-06-2005 12:08 AM
Endianness kelvSYC C++ 3 06-03-2005 02:49 PM
Binary-mode i/o, width of char, endianness T Koster C Programming 15 03-03-2005 07:23 PM
endianness and sscanf/sprintf pramod C++ 22 01-06-2004 01:02 PM



Advertisments