Core API: Special


Embeds a struct into the enclosing struct, merging fields. Can also embed sequences into sequences, merging items. Name is inherited from subcon.


You can use Embedded(Switch(…)) but not Switch(Embedded(…)). Sames applies to If and IfThenElse macros.

Parameters:subcon – the inner struct to embed inside outer struct or sequence


>>> d = Struct("a"/Byte, Embedded(Struct("b"/Byte)), "c"/Byte)
>>> d.parse(b"abc")
construct.Renamed(newname, subcon)

Renames an existing construct. This creates a wrapper so underlying subcon retains it’s original name, which by default is just None. Can be used to give same construct few different names. Used internally by / operator.

Also this wrapper is responsible for building a path (a chain of names) that gets attached to error message when parsing, building, or sizeof fails. Fields that are not named do not appear in the path string.

  • newname – the new name, as string
  • subcon – the subcon to rename


>>> "name" / Int32ul
<Renamed: name>