Package parasol :: Module LikeDict :: Class LikeDict
[hide private]
[frames] | no frames]

Class LikeDict

source code

Dictionary, that has case-insensitive keys. (see SQL LIKE command)

Keys are retained in their original form when queried with .keys() or .items().

Implementation: An internal dictionary maps lowercase keys to (key,value) pairs. All key lookups are done against the lowercase keys, but all methods that expose keys to the user retrieve the original keys.

Instance Methods [hide private]
 
__init__(self, dict=None)
Create an empty dictionary, or update from 'dict'.
source code
 
__getitem__(self, key)
Retrieve the value associated with 'key' (in any case).
source code
 
__setitem__(self, key, value)
Associate 'value' with 'key'.
source code
 
has_key(self, key)
Case insensitive test wether 'key' exists.
source code
 
keys(self)
List of keys in their original case.
source code
 
values(self)
List of values.
source code
 
items(self)
List of (key,value) pairs.
source code
 
get(self, key, default=None)
Retrieve value associated with 'key' or return default value if 'key' doesn't exist.
source code
 
setdefault(self, key, default)
If 'key' doesn't exists, associate it with the 'default' value.
source code
 
update(self, dict)
Copy (key,value) pairs from 'dict'.
source code
 
__repr__(self)
String representation of the dictionary.
source code
 
__str__(self)
String representation of the dictionary.
source code
Method Details [hide private]

__setitem__(self, key, value)
(Index assignment operator)

source code 

Associate 'value' with 'key'. If 'key' already exists, but in different case, it will be replaced.

setdefault(self, key, default)

source code 

If 'key' doesn't exists, associate it with the 'default' value. Return value associated with 'key'.