namespaces

Python dictionaries with items also accessible via dot-notation


License
MIT
Install
pip install namespaces==3.0.0

Documentation

PyPI version Build Status Test Code Coverage

Namespaces are one honking great idea -- let's do more of those!

Install

$ pip install namespaces

API

Namespace is a flexible, mutable version of collections.namedtuple. You can also think about it as a dictionary whose items are also accessible via dot-notation (ie. ns.attr is equivalent to ns['attr']).

The API of Namespace is as follows:

import namespaces as ns
ns = ns.Namespace(a=1, b=2)
fns = ns.FrozenNamespace(ns)
fns.b # => 2
ns.c # => AttributeError
ns.c = 3
ns.c # => 3
fns.c = 3 # => AttributeError

FrozenNamespace is an immutable, hashable Namespace. The hash is lazily computed and is cached for performance.

Tests

unittest

$ python setup.py test