I have a subclass and I want it to not include a class attribute that\'s present on the base class.
I tried this, but it doesn\'t work:
>
You can use delattr(class, field_name) to remove it from the class definition.
Full example:
# python 3
class A:
def __init__(self):
self.field_to_keep = "keep this in B"
self.field_to_delete = "don't want this in B"
class B(A):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
delattr(self, 'field_to_delete')