twisted.python.util.InsensitiveDict

Package twisted :: Package python :: Module util :: Class InsensitiveDict |
[frames | no frames]

## Class InsensitiveDict

Dictionary, that has case-insensitive keys.

Normally keys are retained in their original form when queried with .keys() or .items(). If initialized with preserveCase=0, keys are both looked up in lowercase and returned in lowercase by .keys() and .items().

Method Summary
| ``__init__`(self, dict, preserve)` Create an empty dictionary, or update from 'dict'.
| ``__contains__`(self, key)` Case insensitive test whether 'key' exists.
| `__delitem__(self, key)`
| `__eq__(self, other)`
| ``__getitem__`(self, key)` Retrieve the value associated with 'key' (in any case).
| `__len__(self)`
| ``__repr__`(self)` String representation of the dictionary.
| ``__setitem__`(self, key, value)` Associate 'value' with 'key'.
| `_doPreserve(self, key)`
| `_lowerOrReturn(self, key)`
| `clear(self)`
| `copy(self)`
| ``get`(self, key, default)` Retrieve value associated with 'key' or return default value if 'key' doesn't exist.
| ``has_key`(self, key)` Case insensitive test whether 'key' exists.
| ``items`(self)` List of (key,value) pairs.
| `iteritems(self)`
| `iterkeys(self)`
| `itervalues(self)`
| ``keys`(self)` List of keys in their original case.
| `popitem(self)`
| ``setdefault`(self, key, default)` If 'key' doesn't exists, associate it with the 'default' value.
| ``update`(self, dict)` Copy (key,value) pairs from 'dict'.
| ``values`(self)` List of values.

Method Details

### __init__(self, dict=None, preserve=1) (Constructor) Create an empty dictionary, or update from 'dict'.

### __contains__(self, key) (In operator) Case insensitive test whether 'key' exists.

### __getitem__(self, key) (Indexing operator) Retrieve the value associated with 'key' (in any case).

### __repr__(self) (Representation operator) String representation of the dictionary.

### __setitem__(self, key, value) (Index assignment operator) Associate 'value' with 'key'. If 'key' already exists, but in different case, it will be replaced.

### get(self, key, default=None) Retrieve value associated with 'key' or return default value if 'key' doesn't exist.

### has_key(self, key) Case insensitive test whether 'key' exists.

### items(self) List of (key,value) pairs.

### keys(self) List of keys in their original case.

### setdefault(self, key, default) If 'key' doesn't exists, associate it with the 'default' value. Return value associated with 'key'.

### update(self, dict) Copy (key,value) pairs from 'dict'.

### values(self) List of values.

Generated by Epydoc 2.0 on Sat May 15 20:08:41 2004 | http://epydoc.sf.net