Welcome to namespace
namespace is a Python module that contains a number of (still experimental!) classes to handle containers for named items. It grew out of the common interest on the subject shown by a group of Python programmers that met on the comp.lang.python discussion list. The discussion has been going for sometime now, and several related ideas have already been proposed. Despite the availability of several implementations and recipes, namespace seems to be the first organized attempt at:
- Collecting several related, but still different, classes to handle named items, in a convenient and reusable manner;
- Organizing a module with production-quality code for such specialized classes;
- Writing a PEP with an eye towards future addition as a Python standard library module.
One of the main drivers for the namespace project is to help people to stop reinventing the wheel. It seems to be a common experience to write down simple one-time classes just to group a bunch of named attributes. The classes in the namespace module avoid this, giving the programmer a good foundation to declare such objects in a straighforward manner.
Getting the Module
The current version of module is available from the Trac browser (the download links are at the bottom of that page).
Design Rationale & Discussion
This is a collection of pages explaining some of the reasons behind the design of the classes in the module.
Additionally, there is a mailing list for discussion of the module at Google Groups.
As put out by Steven Bethard, namespace was an outgrowth of his proposed Generic Objects PEP. As the discussion evolved, and based on a number of suggestions, Steven proposed that all related proposals should be grouped under a single namespaces module. In a message to the Python list, Steven listed some reasons:
- Namespace is feeling less and less like a collection to me. Even though it's still intended as a data-only structure, the use cases seem pretty distinct from other collections.
- I think there are a couple different types that should be provided, not just one. For example:
- The suggested namespace view (which allows, for example, globals() to be manipulated with the getattr protocol) should probably be its own class, NamespaceView, since the behavior of a NamespaceView is substantially different from that of a Namespace. (Modifying a NamespaceView modifies the dict, while modifying a Namespace doesn't.) This also allows NamespaceView to have a separate __repr__ to indicate some of the differences.
- The suggested namespace chain, if included, should also probably be its own class, NamespaceChain. As defined, it doesn't depend on Namespace at all -- it could be used just as well for other non-Namespace objects...
As a result, the original Bunch PEP was updated to reflect the new goals, and the Namespace PEP was posted. The namespace project was born shortly afterwards, based on the code that was contributed on the list in the discussion that followed the PEP post.
Notes on Trac
This is a Trac site. Trac is a great software project management tool. It includes a Wiki that's really useful for documentation and several features to track the progress of software development. Some useful links for trac are: