在Python中覆盖嵌套类成员的更好方法是什么?

Dan*_*mov 7 python syntax inheritance class nested-class

我需要"覆盖"一些基类的嵌套类成员,同时保持其余的完整.
这就是我做的:

class InternGenericForm(ModelForm):                
    class Meta:
        model = Intern
        exclude = ('last_achievement', 'program',)
        widgets = {
            'name': TextInput(attrs={'placeholder': '??? ? ???????' }),
        }

class InternApplicationForm(InternGenericForm):
    class Meta:
        # Boilerplate code that violates DRY
        model = InternGenericForm.Meta.model
        exclude = ('is_active',) + InternGenericForm.Meta.exclude
        widgets = InternGenericForm.Meta.widgets
Run Code Online (Sandbox Code Playgroud)

其实,我想InternApplicationForm.Meta完全相同一样InternGenericForm.Meta,不同之处在于它的exclude元组应该包含一个以上的项目.

在Python中这样做的更美妙的方法是什么?
我希望我不必编写样板代码model = InternGenericForm.Meta.model,因为它也容易出错.

Cat*_*lus 16

class InternGenericForm(ModelForm):                
    class Meta:
        model = Intern
        exclude = ('last_achievement', 'program',)
        widgets = {
            'name': TextInput(attrs={'placeholder': '??? ? ???????' }),
        }

class InternApplicationForm(InternGenericForm):
    class Meta(InternGenericForm.Meta):
        exclude = ('is_active',) + InternGenericForm.Meta.exclude
Run Code Online (Sandbox Code Playgroud)