2. Basic Concepts#
In this section, we will introduce some fundamental techniques commonly used when working with binary file formats. These concepts lay the foundation for understanding more advanced topics covered in the next chapter.
Note
To simplify field definitions in your structs, we can use shortcuts. For instance, instead
of manually specifying field types, we can leverage the F
function from the
caterpillar.shortcuts
module to create fields. However, if your don’t want to
wrap everything within a Field
, you can use the as_field
option when packing or unpacking.
>>> from caterpillar.shortcuts import F
>>> field = F(uint8)
or wrap the struct directly
>>> pack(0xFF, uint8, as_field=True)