cf.Configuration¶
-
class
cf.
Configuration
[source]¶ Bases:
cfdm.functions.Configuration
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.New in version (cfdm): 1.8.8.0
Must override this method in subclasses.
Copying¶
Methods
Return a deep copy. |
Dictionary functionality¶
Methods
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. |
|
If key is not found, d is returned if given, otherwise KeyError is raised |
|
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. |
|
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k] |
|
Special¶
Methods
Enter the runtime context. |
|
Exit the runtime context. |
|
Called by the |