cf.Configuration¶
- class cf.Configuration(*args, **kwargs)[source]¶
Dictionary-like container for the global constants.
The container has context manager support.
Initialisation is as for a
dict
, and nearly all of thedict
methods are available with the same behaviours (clear
,fromkeys
,get
,items
,keys
,pop
,popitem
,setdefault
,update
,values
):>>> c = cf.Configuration(atol=0.1, rtol=0.2, log_level='INFO') >>> c <CF Configuration: {'atol': 0.1, 'rtol': 0.2, 'log_level': 'INFO'}> >>> print(c) {'atol': 0.1, 'rtol': 0.2, 'log_level': 'INFO'} >>> c.pop('atol') 0.1 >>> c <CF Configuration: {'rtol': 0.2, 'log_level': 'INFO'}> >>> c.clear() >>> c <CF Configuration: {}>
The
copy
method return a deep copy, rather than a shallow one.Context manager
The
Configuration
instance can be used as a context manager that upon exit executes the function defined by the_func
attribute, with the class itself as input kwargs parameters. For example, theConfiguration
instancec
would executec._func(**c)
upon exit.Added in version (cfdm): 1.8.8.0
Must override this method in subclasses.
Copying¶
Methods
Return a deep copy. |
Dictionary functionality¶
Methods
D.clear() -> None. |
|
Create a new dictionary with keys from iterable and values set to value. |
|
Return the value for key if key is in the dictionary, else default. |
|
D.items() -> a set-like object providing a view on D's items |
|
D.keys() -> a set-like object providing a view on D's keys |
|
D.pop(k[,d]) -> v, remove specified key and return the corresponding value. |
|
Remove and return a (key, value) pair as a 2-tuple. |
|
Insert key with a value of default if key is not in the dictionary. |
|
D.update([E, ]**F) -> None. |
|
D.values() -> an object providing a view on D's values |
Special¶
Methods
Enter the runtime context. |
|
Exit the runtime context. |
|
Called by the |