I am looking to make a dictionary of python file names as the value and the functions defined in each file as the key. I am easily able to make a list of the filenames. For example:
for child in Path('./loaders').iterdir():
if child.is_file():
f = child.name
if f != "__init__.py":
self.beamline_options.append(f.split('.')[0])
I also have a variable defined as self.beamline_loaders = {}, which I would like to add to this loop above in such a way:
for child in Path('./loaders').iterdir():
if child.is_file():
f = child.name
if f != "__init__.py":
self.beamline_options.append(f.split('.')[0])
self.beamline_loaders[f] = [def1, def2, def3, ...]
where def1, def2, ... would be the names of the functions in each file. All of this is within the same module. I am using this dictionary to populate a QComboBox based on the selection of a first combo-box (which consists of just the names in the list of beamline options). This could in theory be hard coded, but I would prefer not to hard code it.
