[Answered ]-How to generate a choicelist from all ImageSpecs

2👍

Well, something like the following will get you a list of all the ImageSpec subclasses defined in the file:

def subclassfilter(x, baseclass):
    return x is not baseclass and isinstance(x, type) and issubclass(x, baseclass)

subclasses = [c for c in locals().values() if subclassfilter(c, ImageSpec)]

You could then generate the choices list from the __name__ attribute of each class in the subclasses list.

Leave a comment