Can't get property value of the superclass
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
super() doesn't work with @classmethod
This doesn't work on micropython (rp2-pico-w-20230302-unstable-v1.19.1-915-g2bcd88d55.uf2) but does work on python3
class Foo:
value = 'test'
@classmethod
def foo(cls):
return cls.value
class Bar(Foo):
@classmethod
def foo(cls):
return super().foo() # also tried super(Bar, cls).foo()
I get the following error:
AttributeError: type object 'type' has no attribute 'value'