Code is much more precise than English; Here's what I'd like to do:
import sys
fileName = sys.argv[1]
className = sys.argv[2]
# open py file here and import the class
# ???
# Instantiante new object of type "className"
a = eval(className + "()") # I don't know if this is the way to do that.
# I "know" that className will have this method:
a.writeByte(0x0)
EDIT:
Per the request of the answers, here's what I'm trying to do:
I'm writing a virtual processor adhering to the SIC/XE instruction set. It's an educational theoretical processor used to teach the fundamentals of assembly language and systems software to computer science students. There is a notion of a "device" that I'm trying to abstract from the programming of the "processor." Essentially, I want the user of my program to be able to write their own device plugin (limited to "read_byte" and "write_byte" functionality) and then I want them to be able to "hook up" their devices to the processor at command-line time, so that they can write something like:
python3 sicsim -d1 dev1module Dev1Class -d2 ...
They would also supply the memory image, which would know how to interact with their device. I basically want both of us to be able to write our code without it interfering with each other.
importing whateverfileNameis because you don't want some of the top level code to run; too bad, you cannot do that! But there are other options, and if you show us some more of your code I'm sure we can show you how, probably by refactoring the "to be imported" fileName