On Thu, Jan 14, 2021 at 10:07 PM Paul Sokolovsky <pmis...@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
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/67KWTWRVFLIJ6OLQHHD25CHQJARXXIKW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to