Namespaces are one honking great idea -- let's do more of those!
$ pip install namespaces
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
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.
$ python setup.py test