EndfVariable
- class endf_parserpy.EndfVariable(endf_path, endf_dict, value=None)[source]
Class to keep a reference to a location in a (nested) dictionary.
An instance of this class is connected to a specific key in a (nested) dictionary and its associated object. The instance attribute
valueallows to set or retrieve the object linked to the specific key in the dictionary. The purpose of this class is to provide a mechanism to pass around objects that can be treated like variables but are always in sync with the data in a given dictionary.Create and associate
EndfVariablewith location in dictionary.- Parameters:
- property name
Name of the associated key in the nested dictionary.
Example
>>> v = EndfVariable('a/b', {'a': {'b': 5}}) >>> assert v.name == 'b'
- property path
Path of associated key in nested dictionary.
Example
>>> d = {'a': {'b': 5}} >>> v = EndfVariable('a/b', d) >>> assert v.path == EndfPath('a/b')
- property value
Value of the associated key in the nested dictionary.
The value of this propert can also be modified, which accordingly modifies the value stored under the associated key in the nested
dict-like object.Example
>>> d = {'a': {'b': 5}} >>> v = EndfVariable('a/b', d) >>> assert v.value == d['a']['b'] >>> v.value = 10 >>> assert d['a']['b'] == 10