For a multitude of reasons I find myself in the position of importing many python modules and wanting to iterate through each of the Classes in the module.
from capacity_hdd_parser import CapacityHDDParser
from capacity_ssd_parser import CapacitySSDParser
from checksum_parser import ChecksumParser
.
.
.
each parser inheritances from a base class and has a method I want to call on each parser
parsers = [CapacityHDDParser, CapacitySSDParser, ChecksumParser]
for parser in parsers:
parser_instance = parser()
data_returned = parser_instance.parse(logset_path)
# Do a bunch of post processing here.
My problem is that I have many parsers to go through and I feel like there has to be a way to dynamically iterate through imported class. Having to hand write each of these is not only a pain in the ass it makes the intent of my code much harder to see in the noise.