tri.struct supplies classes that can be used like dictionaries and as objects with attribute access at the same time
Project description
.. image:: https://travis-ci.org/TriOptima/tri.struct.svg?branch=master
:target: https://travis-ci.org/TriOptima/tri.struct
.. image:: http://codecov.io/github/TriOptima/tri.struct/coverage.svg?branch=master
:target: http://codecov.io/github/TriOptima/tri.struct?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 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
-------
.. code:: python
>>> 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.
=========
Changelog
=========
Here's the recent changes to tri.struct.
.. changelog::
:version: dev
:released: Ongoing
.. change::
:tags: docs
Updated CHANGES.
:target: https://travis-ci.org/TriOptima/tri.struct
.. image:: http://codecov.io/github/TriOptima/tri.struct/coverage.svg?branch=master
:target: http://codecov.io/github/TriOptima/tri.struct?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 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
-------
.. code:: python
>>> 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.
=========
Changelog
=========
Here's the recent changes to tri.struct.
.. changelog::
:version: dev
:released: Ongoing
.. change::
:tags: docs
Updated CHANGES.
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-1.0.0.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for tri.struct-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0304763511e5af6a95d67ce8e6daee583073f46413472888f8b74a26f2e3906 |
|
MD5 | 033abf5c634392d3dfaa0a863e0f211f |
|
BLAKE2b-256 | 2c9e9ea1a87061e0a08fee01a39612c0d01b2e4d19f016e0be69f41a0a26e14a |