python-igraph manual

For using igraph from Python

   Home       Trees       Indices       Help   
Package igraph :: Module utils :: Class multidict
[hide private]

Class multidict

source code

       object --+            
                |            
    _abcoll.Sized --+        
                    |        
       object --+   |        
                |   |        
 _abcoll.Iterable --+        
                    |        
       object --+   |        
                |   |        
_abcoll.Container --+        
                    |        
      _abcoll.Mapping --+    
                        |    
   _abcoll.MutableMapping --+
                            |
                           multidict

A dictionary-like object that is customized to deal with multiple values for the same key.

Each value in this dictionary will be a list. Methods which emulate the methods of a standard Python dict object will return or manipulate the first items of the lists only. Special methods are provided to deal with keys having multiple values.

Nested Classes [hide private]

Inherited from _abcoll.Sized: __metaclass__

Instance Methods [hide private]
 
__init__(self, *args, **kwds)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__contains__(self, key)
Returns whether there are any items associated to the given key.
source code
 
__delitem__(self, key)
Removes all the items associated to the given key.
source code
 
__getitem__(self, key)
Returns an arbitrary item associated to the given key. Raises KeyError if no such key exists.
source code
 
__iter__(self)
Iterates over the keys of the multidict.
source code
 
__len__(self)
Returns the number of distinct keys in this multidict.
source code
 
__setitem__(self, key, value)
Sets the item associated to the given key. Any values associated to the key will be erased and replaced by value.
source code
 
add(self, key, value)
Adds value to the list of items associated to key.
source code
None
clear(self)
Removes all the items from the multidict.
source code
D[k] if k in D, else d
get(self, key, default=None)
Returns an arbitrary item associated to the given key. If key does not exist or has zero associated items, default will be returned.
source code
 
getlist(self, key)
Returns the list of values for the given key. An empty list will be returned if there is no such key.
source code
 
iterlists(self)
Iterates over (key, values) pairs where values is the list of values associated with key.
source code
 
lists(self)
Returns a list of (key, values) pairs where values is the list of values associated with key.
source code
None
update(self, arg, **kwds)
Update D from mapping/iterable E and F.
source code

Inherited from _abcoll.MutableMapping: pop, popitem, setdefault

Inherited from _abcoll.Mapping: __eq__, __ne__, items, iteritems, iterkeys, itervalues, keys, values

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

Class Methods [hide private]

Inherited from _abcoll.Sized: __subclasshook__

Class Variables [hide private]
  __abstractmethods__ = frozenset([])
  _abc_cache = <_weakrefset.WeakSet object at 0x1033fed50>
  _abc_registry = <_weakrefset.WeakSet object at 0x1033fedd0>

Inherited from _abcoll.Mapping: __hash__

Inherited from _abcoll.Mapping (private): _abc_negative_cache_version

Inherited from _abcoll.Sized (private): _abc_negative_cache

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwds)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__contains__(self, key)
(In operator)

source code 
Returns whether there are any items associated to the given key.
Overrides: _abcoll.Container.__contains__

__delitem__(self, key)
(Index deletion operator)

source code 
Removes all the items associated to the given key.
Overrides: _abcoll.MutableMapping.__delitem__

__getitem__(self, key)
(Indexing operator)

source code 

Returns an arbitrary item associated to the given key. Raises KeyError if no such key exists.

Example:

>>> d = multidict([("spam", "eggs"), ("spam", "bacon")])
>>> d["spam"]
'eggs'
Overrides: _abcoll.Mapping.__getitem__

__iter__(self)

source code 
Iterates over the keys of the multidict.
Overrides: _abcoll.Iterable.__iter__

__len__(self)
(Length operator)

source code 
Returns the number of distinct keys in this multidict.
Overrides: _abcoll.Sized.__len__

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

source code 

Sets the item associated to the given key. Any values associated to the key will be erased and replaced by value.

Example:

>>> d = multidict([("spam", "eggs"), ("spam", "bacon")])
>>> d["spam"] = "ham"
>>> d["spam"]
'ham'
Overrides: _abcoll.MutableMapping.__setitem__

add(self, key, value)

source code 

Adds value to the list of items associated to key.

Example:

>>> d = multidict()
>>> d.add("spam", "ham")
>>> d["spam"]
'ham'
>>> d.add("spam", "eggs")
>>> d.getlist("spam")
['ham', 'eggs']

clear(self)

source code 
Removes all the items from the multidict.
Returns: None
Overrides: _abcoll.MutableMapping.clear

get(self, key, default=None)

source code 
Returns an arbitrary item associated to the given key. If key does not exist or has zero associated items, default will be returned.
Returns: D[k] if k in D, else d
Overrides: _abcoll.Mapping.get

update(self, arg, **kwds)

source code 

Update D from mapping/iterable E and F. If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

Returns: None
Overrides: _abcoll.MutableMapping.update
(inherited documentation)

   Home       Trees       Indices       Help