Skip to content

pombredanne/tri.struct

 
 

Repository files navigation

image

image

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

>>> 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.

About

tri.struct supplies classes that can be used like dictionaries and as objects with attribute access at the same time

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 60.3%
  • Python 30.4%
  • C++ 7.2%
  • Makefile 2.1%