Hello, On Thu, 14 Jan 2021 22:14:17 +1100 Chris Angelico <ros...@gmail.com> wrote:
> 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. Yeah, except "monkeypatch" name is unlikely the "best practice" for naming an act of adding a mixin to class, and the question was exactly about "best practices". > 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. Were these complications with the generalization discussed somewhere, so we don't repeat them? I specifically made an angle of particular usecases, like adding mixins or adding typeclasses. While I have a hunch that syntax would be rather similar, it's clear that implementation details of individual decorators will vary. > > ChrisA Thanks! -- Best regards, Paul mailto:pmis...@gmail.com _______________________________________________ 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/LAMEBDYPRYBFMEC2IIYWJBTZTFCACFBS/ Code of Conduct: http://python.org/psf/codeofconduct/