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

ctypes.BigEndianUnion

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


Import

import ctypes
from ctypes import BigEndianUnion

Signature & Overview

ctypes.BigEndianUnion(...)

Union with big endian byte order

Usage

import ctypes

class Raw32(ctypes.BigEndianUnion):
    _fields_ = [("u32", ctypes.c_uint32), ("bytes", ctypes.c_uint8 * 4)]

u = Raw32(u32=0x01020304)
assert list(u.bytes) == [1, 2, 3, 4]

Gotchas

REPL Inspect

from ctypes import BigEndianUnion
help(BigEndianUnion)

Linked from

Related notes