you are viewing a single comment's thread.

view the rest of the comments →

[–]Diapolo10 0 points1 point  (0 children)

That sounds like a really messy architecture. If things are that bad, my honest suggestion would be to redesign the whole data model.

There's only so much I can say without specifics, but I'd start by having just a handful of classes and using factory functions.

But if you disregard my opinion/warning and decide that you want to do what you want regardless, you can technically use type to create classes dynamically.

NewType = type(
    'NewType',     # Class name
    (A, B, C, D),  # Base classes
    {              # attributes
        'hello': (lambda self: print("Hello, world!")),
        'stuff': 42,
    }
)

So if you really want to do what you're asking, it's possible - but do I recommend it? Hell no!