This work for me :
class ParametersGeneral:
def __init__(self, section_name, enable_adjacent_channel=False, enable_cochannel=False, num_snapshots=10000, imt_link='DOWNLINK', system='RAS', seed=101, overwrite_output=True, is_space_to_earth=False, output_dir='output', output_dir_prefix='output'):
self.section_name = section_name
self.enable_adjacent_channel = enable_adjacent_channel
self.enable_cochannel = enable_cochannel
self.num_snapshots = num_snapshots
self.imt_link = imt_link
self.system = system
self.seed = seed
self.overwrite_output = overwrite_output
self.output_dir = 'output'
self.output_dir_prefix = 'output'
self.is_space_to_earth = is_space_to_earth
self.output_dir = output_dir
self.output_dir_prefix=output_dir_prefix
for attr in attr_list:
try:
attr_val = getattr(self, attr)
config_value = config[self.section_name][attr]
print(f"Setting attribute '{attr}' with value from config: {config_value} (type: {type(config_value)})")
if isinstance(attr_val, str):
setattr(self, attr, config_value)
elif isinstance(attr_val, bool):
setattr(self, attr, bool(config_value))
elif isinstance(attr_val, float):
setattr(self, attr, float(config_value))
elif isinstance(attr_val, int):
setattr(self, attr, int(config_value))
elif isinstance(attr_val, tuple):
try:
param_val = config_value
tmp_val = list(map(float, param_val.split(",")))
setattr(self, attr, tuple(tmp_val))
except ValueError:
print(f"ParametersBase: could not convert string to tuple \"{self.section_name}.{attr}\"")
exit()
except KeyError:
print(f"ParametersBase: NOTICE! Configuration parameter \"{self.section_name}.{attr}\" is not set in configuration file. Using default value {attr_val}")
except Exception as e:
print(f"Um erro desconhecido foi encontrado: {e}")