I am new to python. I'm writing a testing application for another analytical tool. That tool outputs various kinds of files we call 'artifacts'. Each type of artifact is a data file of some kind.
I created a parent class called Artifact that has load() and compare() functions.
So, say I have two types of artifacts: cube and report. Each has an associated Cube and Report class, with functions that know how to read the respective data, and compare one to another (one cube to another cube and one report to another report).
Implementing that is all clear to me.
Here's my question: I'd like users to be able to implement their own new Artifacts that I'm not aware of now, and be able to load them via a config file.
The new child of Artifact would need to be a .py file, but I would like to not have to alter the code of the main test application. So I'd like the users to specify in a config file to use existing Cube and Report artifacts, as well as their newly defined artifact. For all artifacts do a load() and compare()
Can I do this without doing an explicit import of the new class, and without specify an Explicit call to it?
Can I just write
for c in Artifact classes:
c.load()
c.compare()
? (that's obviously simplified, I hope it's clear)
Artifact) based on user input? Such ismy_class = ./CustomArtifact.py? And YOUR code would need to operate on that class, and not the other way around?importlibmodule.