I have searched high and low and can't find a proper solution.
I need to dynamically create objects and store them in dictionaries using a for loop from a class that is in a different file.
To avoid name space pollution I like to import my modules like so:
from my_folder import my_file as mf
the loop looks like this:
self.my_dict = {} # create empty dictionary
for F in ('One', 'Two', 'Three', ...):
object = F(var1, var2)
self.my_dict[F] = object
on the line object = F(var1, var2)
I need the F
be referring to mf.One
,
mf.Two
and so on.
How do I append the value F
to mf
so it reads it as mf.value-of-F
instead of reading it as mf.F
?
I know I must be missing something very obvious, just not obvious to me right now. Thanks