I'm giving in command line arguments to a Python script, two of which are the python file name and the class I'd like to import. How can I define the module and import it during runtime in my __main__
function?
Thanks!
ap=argparse.ArgumentParser()
ap.add_argument("-f", "--filename", help="the path to the file where the imaging class is located")
ap.add_argument("-c", "--class", help="name of the class to be imported")
args = vars(ap.parse_args())
filename = args["filename"]
imagingClass = args["class"]
from [filename] import [class] # <-- this part