Using a C-header file in Python

andyabel member7758 at dbforums.com
Wed Apr 30 13:45:35 EDT 2003


I have a binary data file that I'd like to read from Python.
The file is complex and is described by a 3rd-party C-header file with
definitions like the following:

#define  TRANS_LEN                      64
struct trs_general_
{
    unsigned char opcode;
    unsigned char sub_opcode;
    unsigned char data[TRANS_LEN - 2 - sizeof(struct trans_tail_)];
    struct   trans_tail_  tail;
}
(And trans_tail_ is also defined as a struct in the file etc.)

Can I "include" this C-header file in my Python program (without
altering the header file) so I can read the file using standard Python
filehandling functions.

Thanks! (Please keep the answer simple, I'm a newbie to Python :-)

--
Posted via http://dbforums.com




More information about the Python-list mailing list