[plum] Utility Reference: unpack_from()

plum.unpack_from(fmt, buffer, offset=None)

Unpack item from within a bytes buffer.

Parameters:
  • fmt (Plum, tuple of Plum, or dict) – plum type, tuple of types, or dict of types
  • buffer (bytes-like (e.g. bytes, bytearray, memoryview) or binary file) – bytes buffer
  • offset (int) – starting byte offset (None indicates current file position)
Returns:

unpacked items

Return type:

Plum, tuple of Plum, or dict of Plum (dependent on fmt)

Raises:

UnpackError if insufficient bytes or value error

For example:
>>> from plum import unpack_from
>>> from plum.int.little import UInt8
>>>
>>> buffer = b'\x99\x01\x99'
>>> offset = 1
>>>
>>> unpack_from(UInt8, buffer, offset)
1