我有一些像這樣的代碼Django-Tastypie:如何在Python中訪問超類的元屬性?
class SpecializedResource(ModelResource):
class Meta:
authentication = MyCustomAuthentication()
class TestResource(SpecializedResource):
class Meta:
# the following style works:
authentication = SpecializedResource.authentication
# but the following style does not:
super(TestResource, meta).authentication
我想知道什麼是訪問超類的元屬性沒有硬編碼的超類的名稱正確的方法。
在提供超類名稱的片段中沒有硬編碼 - 'super()'採用* current *類的名稱。 –
正如評論所說,它不起作用:P –