
Jan. 14, 2021
11:14 a.m.
On Thu, Jan 14, 2021 at 10:07 PM Paul Sokolovsky <pmiscml@gmail.com> wrote:
The question then: what are the best practices in *declarative* syntax to achieve the same effect in Python? (but of course, unlike Ruby, there should be explicit syntactic marker that we augment existing class, not redefine it).
Easy. @monkeypatch class Cls: ... And then you define monkeypatch as a function that locates the prior class, augments it, and returns it. If you actually want this, it's only about a dozen lines of code. The trouble is, it's nearly impossible to generalize which things should be lifted in and which shouldn't, so it basically has to be written for each use-case. ChrisA