Skip to main content

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.

Project details


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)

Uploaded Source

Built Distribution

tri.struct-0.3.0-py2.py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page