HexBytes

HexBytes is a very thin wrapper around the python built-in bytes class.

It adds these features:

  1. Accepts more types for initializing values:

    • bool

    • bytearray

    • bytes

    • int (non-negative)

    • str

    • memoryview

  2. The representation at console (__repr__) is 0x-prefixed

  3. to_0x_hex returns a 0x-prefixed hex string

Installation

python -m pip install hexbytes