On this page
  1. ctypes.BigEndianStructure
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

ctypes.BigEndianStructure

Prev: ctypes.Array | Up: ctypes | Next: ctypes.BigEndianUnion
Rel: ctypes.addressof, ctypes.alignment, ctypes.ArgumentError, ctypes.Array
Ref: docs.python.org — ctypes.BigEndianStructure
Tags: #public #python3 #stdlib #ctypes


Import

import ctypes
from ctypes import BigEndianStructure

Signature & Overview

ctypes.BigEndianStructure(...)

Structure with big endian byte order

Usage

import ctypes

class NetHeader(ctypes.BigEndianStructure):
    _pack_ = 1
    _fields_ = [("version", ctypes.c_uint8), ("length", ctypes.c_uint16)]

h = NetHeader.from_buffer_copy(b"\x01\x00\x2a")
assert (h.version, h.length) == (1, 42)

Gotchas

REPL Inspect

from ctypes import BigEndianStructure
help(BigEndianStructure)

Linked from

Related notes