Field Helpers

Structured arrays are described as a sequence of fields. Each field can be defined as a Field or as a tuple compatible with the Field structure.

A constant READ_ONLY equivalent to the boolean value True is provided to make the code more readable when setting the Field.read_only attribute without explicitely writing the read_only keyword. Example:

>>> import nani
>>> data_type = nani.Structure(
...     fields=(
...         ('do_not_touch', nani.Number(), nani.READ_ONLY),
...     )
... )
Field Describe a field of a structured array.
READ_ONLY Constant to use for the Field.read_only attribute’s value.

class nani.Field(name, type, read_only=False)[source]

Describe a field of a structured array.

name

str – Name of the field.

type

nani data type – Type of the field.

read_only

boolTrue to not define a setter property in the structured array view if it is set to be dynamically generated by Nani.


nani.READ_ONLY = True

Constant to use for the Field.read_only attribute’s value. To use for readability reasons when the read_only keyword is not explicitely written.