----- Original Message -----
> From: "Peter Otten" <__pete...@web.de>
> becomes
> 
> $ cat be2.py
> import ctypes, sys
> 
> iarray_be = ctypes.c_uint32.__ctype_be__*5
> 
> class Foo_be(ctypes.BigEndianStructure):
>         _fields_ = [('bar', iarray_be)]
> 
> print sys.version
> f_be = Foo_be((0,1,2,3,0x11223344))
> print hex(f_be.bar[4])
> 
> $ python be2.py
> 2.7.6 (default, Mar 22 2014, 22:59:56)
> [GCC 4.8.2]
> 0x11223344L
> 
> which might do what you want.

Brilliant !

I've tested it and it yields the exact same results (binary file content wise) 
than my "workaround" structure.
But that's way better since my actual structure is more complex and arrays will 
be required.

Though I'm slightly puzzled by the ctypes author(s) choice, this is not 
documented and requires to peek into the source code. Dunder attributes are 
rarely part of an interface.

Anyway, thanks for your help !

JM



-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to