I have a class in which I have properties that are returning arrays. For simplicity, let’s consider them constant: Now, I have another class which is inheriting MyClass and it is interpolating the data, for example: Now, the issue is that I have 2 classes like MyClass and each one of them consists of ~30 properties. Is there a way
Tag: overriding
How to check if string exists in Enum of strings?
I have created the following Enum: I have inherited from str, too, so that I can do things such as: I would now like to be able to check if a string is in this Enum, such as: I have tried adding the following method to the class: However, when I run this code: I get this exception: Answer I
Overriding Django-Rest-Framework serializer is_valid method
I have a quick question about overriding is_valid. Self is a rest_framework.serializers.ModelSerializer. I’m trying to figure out if there is a better way to modify internal data than reading/writing to the data._kwargs property. I know I can get the data pre-validation via a self.get_initial() call. But I’d also like to be able to write data. The purpose here is to
Overriding in Python
I want to be able to do the following I would like to get a parent function from a child class in a function that is overriding it. I am not sure how to do this. This is a little hard to explain, comment if you are having trouble understanding. Edit: Thanks for the answers everyone, I almost thought that