tri.struct¶
tri.struct supplies classes that can be used like dictionaries and as objects with attribute access at the same time. There are two versions:
- Struct: mutable struct
- FrozenStruct: immutable struct
Some niceties include:
- Predictable repr() so it’s easy to write tests
- merged function call to merge different types of dicts into a new: merged(Struct(a=1), FrozenStruct(b=1), c=1) == Struct(a=1, b=1, c=1))
- Accelerated implementation in c for improved speed. (With python-only fallback reference implementation)
Example¶
>>> from tri_struct import Struct
>>> foo = Struct()
>>> foo.a = 1
>>> foo['a']
1
>>> foo['a'] = 2
>>> foo.a
2
Running tests¶
You need tox installed then just make test.
License¶
BSD
Documentation¶
Contents:¶
- Installation
- API documentation
- History
- 3.1.0 (2019-08-14)
- 3.0.1 (2019-06-12)
- 3.0.0 (2019-06-04)
- 2.5.7 (2018-11-16)
- 2.5.6 (2018-06-26)
- 2.5.5 (2018-02-20)
- 2.5.4 (2017-06-13)
- 2.5.3 (2017-02-10)
- 2.5.2 (2016-04-07)
- 2.5.1 (2015-12-15)
- 2.5.0 (unreleased)
- 2.4.0 (2015-12-08)
- 2.3.1 (2015-12-07)
- 2.3.0 (2015-12-02)
- 2.2.0 (2015-11-12)
- 2.1.2 (2015-11-11)
- 2.0 (unreleased)
- 1.0 (2015-09-29)
- Credits
- Contributing