The NamedValues class associates human-friendly names to a set of numbers or bits.

class pyasn1.type.namedval.NamedValues(*args, **kwargs)

Create named values object.

The NamedValues object represents a collection of string names associated with numeric IDs. These objects are used for giving names to otherwise numerical values.

NamedValues objects are immutable and duck-type Python dict object mapping ID to name and vice-versa.

  • *args (variable number of two-element tuple)

  • **kwargs (keyword parameters of:) –

    name: str

    Value name

    value: int

    A numerical value


>>> nv = namedval.NamedValues('a', 'b', ('c', 0), d=1)
>>> nv
>>> {'c': 0, 'd': 1, 'a': 2, 'b': 3}
>>> nv[0]
>>> nv['a']