By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,587 Members | 1,731 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,587 IT Pros & Developers. It's quick & easy.

What's your choice when handle complicated C structures.

P: n/a
Hi all,

Recently I am writing a small network application with python.

The protocol is binary based and defined in c header files.

Now I'm using the upack function of 'struct' module, but it's really
annoying to write fmt strings for complicated structures.

What will be your choice when handling binary structures?
Nov 5 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
一首诗 schrieb:
Hi all,

Recently I am writing a small network application with python.

The protocol is binary based and defined in c header files.

Now I'm using the upack function of 'struct' module, but it's really
annoying to write fmt strings for complicated structures.

What will be your choice when handling binary structures?
You can try gccxml + ctypes instead.

Diez
Nov 5 '08 #2

P: n/a
Recently I am writing a small network application with python.
>
The protocol is binary based and defined in c header files.

Now I'm using the upack function of 'struct' module, but it's really
annoying to write fmt strings for complicated structures.

What will be your choice when handling binary structures?
I would write a couple of wrapper functions around unpack of struct so
that the actual unpacking is less annoying but otherwise would
continue using the same approach as what you describe.

Cheers,
Daniel
--
Psss, psss, put it down! - http://www.cafepress.com/putitdown
Nov 5 '08 #3

P: n/a
On Tue, 04 Nov 2008 16:52:17 -0800, 一首诗 wrote:
Now I'm using the upack function of 'struct' module, but it's really
annoying to write fmt strings for complicated structures.

What will be your choice when handling binary structures?
http://construct.wikispaces.com/

Ciao,
Marc 'BlackJack' Rintsch
Nov 5 '08 #4

P: n/a
一首诗 wrote:
Hi all,

Recently I am writing a small network application with python.

The protocol is binary based and defined in c header files.

Now I'm using the upack function of 'struct' module, but it's really
annoying to write fmt strings for complicated structures.

What will be your choice when handling binary structures?
I use numpy and its nested dtypes. But then, I use numpy for damn near everything.

http://numpy.scipy.org/

Construct also looks appropriate.

http://construct.wikispaces.com/

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Nov 5 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.