attrdict

Classes

class jnrbase.attrdict.AttrDict[source]

Dictionary with attribute access.

See also: dict

__delattr__(_AttrDict__key)[source]

Support item deletion via dot notation.

Parameters

__key – Key to delete

Return type

None

__getattr__(_AttrDict__key)[source]

Support item access via dot notation.

Parameters

__key – Key to fetch

Return type

Any

__setattr__(_AttrDict__key, _AttrDict__value)[source]

Support item assignment via dot notation.

Parameters
  • __key – Key to set value for

  • __value – Value to set key to

Return type

None

class jnrbase.attrdict.ROAttrDict[source]

Read-only dictionary with attribute access.

See also: AttrDict

__setattr__(*args)

Handle attempt to modify read-only dictionary.

Raises

AttributeError – On modification attempt

Examples

>>> ad = AttrDict(a=1, b=2)
>>> ad.a
1
>>> ad.b += 1
>>> ad.b
3

>>> ro_ad = ROAttrDict()
>>> ro_ad.c = 1
Traceback (most recent call last):
  ...
AttributeError: <class 'jnrbase.attrdict.ROAttrDict'> is read-only