class Class1(object):
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
class Class2(object):
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
module = importlib.import_module('my_module_name')
classes = [
value
for value in (
getattr(module, name)
for name in dir(module)
)
if isinstance(value, type)
and getattr(value, '__module__', None) == module.__name__
]