Re: FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-06-04 Thread p . lavarre
http://docs.python.org/lib/module-pickle.html ... concise Python ways of pickling and unpickling the (0xFF ** N) possible ways of packing N strings of byte lengths of 0..xFE together ... Aye, looks like an exercise left open for the student to complete: pickle.dumps() S''\np0\n.

Re: FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-06-01 Thread p . lavarre
Often it helps to ask yourself the question: How would I do this in C? ... *Not* by using a structure. A structure is fine if the definition is fixed, or at most has *one* variable sized field at the very end. http://docs.python.org/lib/module-pickle.html might be near where I'll find concise

FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-05-31 Thread p . lavarre
How do I vary the byte offset of a field of a ctypes.Structure? How do I use the dynamic nature of Python, and (re-)define the data type after the required size is already known, on a case by case basis? \\\ For example, suppose sometimes I receive the value '\x03hi' + \x04bye' for the struct:

Re: FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-05-31 Thread Larry Bates
[EMAIL PROTECTED] wrote: How do I vary the byte offset of a field of a ctypes.Structure? How do I use the dynamic nature of Python, and (re-)define the data type after the required size is already known, on a case by case basis? \\\ For example, suppose sometimes I receive the value

Re: FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-05-31 Thread Thomas Heller
[EMAIL PROTECTED] schrieb: How do I vary the byte offset of a field of a ctypes.Structure? How do I use the dynamic nature of Python, and (re-)define the data type after the required size is already known, on a case by case basis? \\\ For example, suppose sometimes I receive the value

Re: FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-05-31 Thread p . lavarre
ctypes.sizeof(a) is still zero, as if ctypes.Structure.__init__ fetches a.__class__._fields_ rather than a._fields_ -- http://mail.python.org/mailman/listinfo/python-list

Re: FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-05-31 Thread p . lavarre
Thomas, Ouch ouch I must have misunderstood what you meant by use the dynamic nature of Python, and (re-)define the data type after the required size is already known, on a case by case basis. Do you have an example of what you meant? I searched but did not find. Are those your words? Yes, to

Re: FAQ: how to vary the byte offset of a field of a ctypes.Structure

2007-05-31 Thread p . lavarre
I see that changing self._fields_ doesn't change ctypes.sizeof(self). I guess ctypes.Structure.__init__(self) fetches self.__class__._fields_ not self._fields_. -- http://mail.python.org/mailman/listinfo/python-list