cf.CfDict

class cf.CfDict(*args, **kwargs)

Bases: _abcoll.MutableMapping

A dictionary-like object with attributes.

Initialization

Parameters :
args, kwargs :

Keys and values are initialized exactly as for a built-in dict.

CfDict methods (undocumented methods behave exactly as their counterparts in a built-in dictionary)

clear
copy Return a deep copy.
equals True if two instances are logically equal, False otherwise.
get
get_keys Return a list of the key names which match a regular expression.
has_key Return true if and only if the dictionary contains the given key.
items
iteritems
iterkeys
itervalues
keys
pop
popitem
setdefault
update
values
copy()

Return a deep copy.

Equivalent to copy.deepcopy(d).

Returns :
out :

The deep copy.

Examples

>>> d.copy()
equals(other, rtol=None, atol=None, traceback=False)

True if two instances are logically equal, False otherwise.

Parameters :
other :

The object to compare for equality.

atol : float, optional

The absolute tolerance for all numerical comparisons, By default the value returned by the ATOL function is used.

rtol : float, optional

The relative tolerance for all numerical comparisons, By default the value returned by the RTOL function is used.

traceback : bool, optional

If True then print a traceback highlighting where the two instances differ.

Returns :
out : bool

Whether or not the two instances are equal.

Examples

get_keys(regex=None)

Return a list of the key names which match a regular expression.

Parameters :
regex : str, optional

The regular expression with which to identify key names. By default all keys names are returned.

Returns :
out : list

A list of key names.

Examples

>>> d.keys()
['dim2', 'dim0', 'dim1', 'aux0', 'cm0']
>>> d.get_keys()
['dim2', 'dim0', 'dim1', 'aux0', 'cm0']
>>> d.get_keys('dim')
['dim2', 'dim0', 'dim1']
>>> d.get_keys('^aux|^dim')
['dim2', 'dim0', 'dim1', 'aux0']
>>> d.get_keys('dim[1-9]')
['dim2', 'dim1']
has_key(key)

Return true if and only if the dictionary contains the given key.

Parameters :
key : hashable object

The key.

Returns :

out : bool

Examples

>>> d.keys()
['key1', 3, ('a', 1)]
>>> d.has_key(3)
True
>>> d.has_key('key9')
False

Previous topic

cf.Filearray

Next topic

cf.CfList

This Page