Skip to content
Discussion options

You must be logged in to vote

@jmtinycircuits Unfortunately for optimisation/space reasons there are several limitations placed on inheritance from built-in types. This stems from the fact that inheritance from built-in (native) types works differently to inheritance from instance types.

The main thing to be aware of is that a type's attr handler is not equivalent to Python's __setattr__ (i.e. it's not polymorphic). Which is why this works in Python (and MicroPython):

class Base:
    def __setattr__(self, n, v):
        print("base set", n, v)

class Derived(Base):
    pass


d = Derived()
d.foo = "hello"

(when the store to d.foo is resolved, it sees Derived as having a __setattr__ method)

Unfortunately I don't see a…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant