Package pyraf :: Module minmatch
[hide private]
[frames] | no frames]

Module minmatch

source code

minmatch.py: Dictionary allowing minimum-match of string keys

Entries can be retrieved using an abbreviated key as long as the key is unambiguous. __getitem__ and get() raise an error if the key is ambiguous.

A key is not consider ambiguous if it matches a full key, even if it also is an abbreviation for a longer key. E.g., if there are keys 'spam' and 'spameggs' in the dictionary, d['spam'] returns the value associated with 'spam', while d['spa'] is an error due to ambiguity.

New key/value pairs must be inserted using the add() method to avoid ambiguities with when to overwrite and when to add a new key. Assignments using setitem (e.g. d[key] = value) will raise an exception unless the key already exists and is unambiguous.

The getall(key) method returns a list of all the matching values, containing a single entry for unambiguous matches and multiple entries for ambiguous matches.

$Id: minmatch.py 678 2005-07-01 21:19:43Z perry $

R. White, 2000 January 28

Classes [hide private]
  AmbiguousKeyError
  MinMatchDict
  QuietMinMatchDict
Minimum match dictionary that does not raise unexpected AmbiguousKeyError

Imports: copy, StringType, UserDict