← index #2720Issue #18741
Duplicate · high · value 1.287
QUERY · ISSUE

Can't get property value of the superclass

openby nuphaopened 2016-12-25updated 2023-03-06
bug

As following code shows, a subclass to override property 'p' of superclass. Calling super().p in subclass will return a property object, not the value. Further more, this property object has no .fget attribute as suggested in standard python. But a 'getter' method is found on property object, when I call .getter(o), another property object returned, still not value.

So, I can't get the property value of superclass. Any suggestion?

class A:
@property
def p(self):
return {"a":10}

class AA(A):
@property
def p(self):
# get super property, add some new value
v = super().p
v['aa'] = 20 # this will raise an exception, because v is a property object, not a dict
return v

CANDIDATE · ISSUE

super() does not support properties

closedby smurfixopened 2026-01-29updated 2026-01-29
bug

Port, board and/or hardware

any

MicroPython version

current master

Reproduction

class A:
    @property
    def name(self):
        return "Foo"

class B(A):
    @property
    def name(self):
        return super().name+"Bar"

print(B().name)

Expected behaviour

MicroPython: "FooBar"

Observed behaviour

Python: "FooBar"
MicroPython: TypeError: unsupported types for __add__: 'property', 'str'

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied