January 17th, 2005, 01:41 PM
Join Date: Jan 2005
Location: Bay area
Time spent in forums: 16 m 41 sec
Reputation Power: 0
Hello forum -
I'm fairly new to python, and the task I've set myself may be over my head, but let me describe what I want, and see if it makes sense...
I have my project structured something like this:
So - when I run my main.py, I would like it to load any 'derived_class' that is in the modules folder. I want to be able to just drop new class in that folder, and have them be added automatically.
So I've been playing with the os library, and I can get a list of the files in the modules folder. Then I can do some string manipulation, and the eval() function to load the class (provided the class has the same name as the file).
It seems rather sloppy though. I think I must be missing something. Do you have any suggestions on how to accomplish this more efficiently?