A Python class: named objects with name spaces

Allan M. Stavely

April 10, 2006; last modified March 12, 2009


Table of Contents

1. Introduction
2. Usage
3. Implementation
3.1. Creating an object with a given name
3.2. Finding the object with a given name

1. Introduction

This document presents code in the Python language to implement named objects. Such an object will have a name that identifies it uniquely within a given name space, like a primary key in a database relation. I expect that the names will usually be strings, but the only requirement is that a name must be usable as a key in a Python dictionary. This excludes only mutable types such as lists and other dictionaries.

The fundamental operations on such objects will be:

  • to create an object with a given name

  • to find the object with a given name, if there is one