I created several Python classes for use as multidimensional data structures, which are then used for various tasks. In some cases, I like to populate classes with different sets of values. By default, the filename parameter "ho2.defaults" will look something like this:
name = 'ho2'
mass_option = 'h1o16'
permutation = 'odd'
parity = 'odd'
j_total = 10
lr = 40
br = 60
jmax = 60
mass_lr = 14578.471659
mass_br = 1781.041591
length_lr = ( 1.0, 11.0, 2.65 )
length_br = ( 0.0, 11.0, 2.46 )
use_spline = True
energy_units = 'au'
pes_zpe = -7.407998138300982E-2
pes_cutoff = 0.293994
I am currently creating a dictionary to read the desired key, a pair of values from a file, and now I need a "pythonic" way to make these dictionary keys be the instance names of the instance class, i.e.
# Instantiate Molecule Class
molecule = Molecule()
# Create Dictionary of default values
default_dict = read_dict_from_file(filename)
# Set populate class instance variables with dictionary values
for key,value in default_dict:
molecule.key = value
, "." , . , , . , , , . ?