Skip to content

property inheritance: not able to call properties from parent classes #1507

@TG-Techie

Description

@TG-Techie

the code below returns this error:

Traceback (most recent call last):
File "main.py", line 39, in
File "/file_location", line ###, in val
AttributeError: 'super' object has no attribute 'val'

class parent():
    def __init__(self, initval):
        self._val = initval

    @property
    def val(self):
        return self._val

    @val.setter
    def val(self, valin):
        self._val = valin
        print('in parent')

def child(parent):

    @property
    def val(self):
        return super()._val

    @val.setter
    def val(self, valin):
        super().val = valin
        print('in child')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions