Package pology :: Module multi :: Class Multidict

Class Multidict

object --+
         |
        Multidict

Several dictionaries readable as one.

Allows to get elements from several dictionary-like sequences as if they were one, without really creating a single union of items from all of them. This is useful when it is more expensive to create the union, than to look sequentially in each dictionary in turn.

All methods named same as in dict have same semantics too.

Instance Methods
 
__init__(self, dicts)
Constructor.
 
__contains__(self, key)
 
__getitem__(self, key)
 
__iter__(self)
 
get(self, key, defval=None)
 
iterkeys(self)
 
itervalues(self)
 
iteritems(self)

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, dicts)
(Constructor)

 

Constructor.

Order of dictionaries in the list matters, firstmost has highest priority when looking for a key.

Collected sequences need to implement the following methods of a dictionary: __getitem__, __contains__, iterkeys, itervalues, iteritems. Iterators have to implement next method, and raise StopIteration when exhausted.

Parameters:
  • dicts (list of dict) - sequence of dictionary-like objects
Overrides: object.__init__