PyDocs

Nav

Generic Operating System Services

Structure

ctypes

class
  • Structure(*args, **kw)
Structure base class
Members of Structure

_

_align_
An optional small integer that allows increasing the alignment of the structure when being packed or unpacked to/from memory.
_anonymous_
An optional sequence that lists the names of unnamed (anonymous) fields.
_fields_
A sequence defining the structure fields.
_layout_
An optional string naming the struct/union layout.
_pack_
An optional small integer that allows overriding the alignment of structure fields in the instance.
1 Example
>>> from ctypes import *
>>> class POINT(Structure):
...     _fields_ = [("x", c_int),
...                 ("y", c_int)]
...
>>> point = POINT(10, 20)
>>> print(point.x, point.y)
10 20
>>> point = POINT(y=5)
>>> print(point.x, point.y)
0 5
>>> POINT(1, 2, 3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: too many initializers
>>>
from the Python docs
See Also
No see-alsos for ctypes/Structure
0 Notes
No notes for Structure