1

If I have a class like this:

class A(object): def __init__(self): self.dynamic_objects = [] 

And a subfolder in the same location with a variable amount of files each with one class that are child of the same parent class (in other words they have the same methods and variables):

class B(Parent): def run(self): # logic here return 

How could I go about making the list of dynamic_objects in class A automatically populate one object for each file in the subfolder? So if my file structure is like this:

a.py /subfolder b.py c.py d.py 

How could I make it so that the dynamic_objects list is filled with one B object, one C object, and one D object without hardcoding it in that list but just pointing it to the directory? Is this possible?

I want to do this in my application so that anyone who wants to extend the functionality of the app can just worry about making a class with a run method in the subfolder without having to edit a.py

1

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.