No project description provided
Project description
tri.struct supplies classes that can be used like dictionaries and as objects with attribute access at the same time. There are three classes:
Struct: mutable struct
FrozenStruct: immutable struct
NamedStruct: mutable struct with restrictions on which fields can be present
Some niceties include:
Predictable repr() so it’s easy to write tests
Plus operator for Struct (Struct(a=1) + Struct(b=1) == Struct(a=1, b=1))
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tri.struct-0.1.0.tar.gz
(5.1 kB
view hashes)
Built Distribution
Close
Hashes for tri.struct-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3b7eb54b0890774996f081d4ce00bc428786aa40d4ca2c0f9edc6b1fde792bd |
|
MD5 | b3233d968570b39b8c07f7ae6ec14281 |
|
BLAKE2b-256 | cbc1fe234f7ce0b35ce803412f63b846391eca35e46166a475f2c6631244055c |