Skip to content
tri.struct supplies classes that can be used like dictionaries and as objects with attribute access at the same time
C Python C++ Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
lib/tri_struct
tests
.coveragerc
.gitignore
.travis.yml
AUTHORS.rst
CONTRIBUTING.rst
HISTORY.rst
LICENSE
MANIFEST.in
Makefile
README.rst
TODO
codecov.yaml
requirements.txt
setup.cfg
setup.py
test_requirements.txt
tox.ini
venv_requirements.txt

README.rst

https://travis-ci.org/TriOptima/tri.struct.svg?branch=master http://codecov.io/github/TriOptima/tri.struct/coverage.svg?branch=master

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

http://tristruct.readthedocs.org.

You can’t perform that action at this time.