API documentation

class tri_struct.Struct

Struct is a dict that can be accessed like an object. It also has a predictable repr so it can be used in tests for example.

>>> bs = Struct(a=1, b=2, c=3)
>>> bs
Struct(a=1, b=2, c=3)
>>> bs.a
1
  • Struct(**kwargs) -> new Struct initialized with the name=value pairs in the keyword aasdrgument list. For example: Struct(one=1, two=2)

  • Struct() -> new empty Struct

  • Struct(mapping) -> new Struct initialized from a mapping object’s (key, value) pairs

  • Struct(iterable) -> new Struct initialized as if via:
    s = Struct()
    for k, v in iterable:
        s[k] = v
    
__delattr__(item)[source]

x.__delattr__(‘name’) <==> del x.name

__getattribute__(item)[source]

x.__getattribute__(‘name’) <==> x.name

__repr__() <==> repr(x)[source]
__setattr__(key, value)[source]

x.__setattr__(‘name’, value) <==> x.name = value

__str__()

x.__repr__() <==> repr(x)

copy() → a shallow copy of D[source]
class tri_struct.FrozenStruct[source]
tri_struct.merged(*dicts, **kwargs)[source]

Merge dictionaries. Later keys overwrite.

merged(dict(a=1), dict(b=2), c=3, d=1)
class tri_struct.DefaultStruct(default_factory=None, *args, **kwargs)[source]
__init__(default_factory=None, *args, **kwargs)[source]

x.__init__(…) initializes x; see help(type(x)) for signature