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
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
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-0.3.0.tar.gz
(5.2 kB
view hashes)
Built Distribution
Close
Hashes for tri.struct-0.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50a7c01ba146296b26fde517e84c24b39e341fe1228be44128ce6f88e334d8fb |
|
MD5 | b3d4195bb0890d96d9ffcd30cc662a59 |
|
BLAKE2b-256 | ca4c03717745435589cf1384afa8a4badf1c9e1a60dc41bd00e50a1dc657e3e1 |