On 2021-06-20 at 12:18:24 -0000, Johan Vergeer email@example.com wrote:
After working with Kotlin for a while I really started to like the idea of extension methods. I delivers a great way to extend the language without having to add features to the language itself.
I disagree with the premise that such a thing is great, although it does have limited use cases (mostly revolving around bugs, whether you know about the bug or are tracking it down).
That said, Python already allows it:
>>> class C: pass >>> c = C() >>> C.f = lambda self, *a: a # add method f to class C >>> c.f(5, 6) (5, 6)