Re: Metaclasses in traitlets and PEP 487
Thomas Kluyver <[email protected]>
| Newsgroups | gmane.comp.python.ipython.devel |
|---|---|
| Message-ID | <CAOvn4qgOkHJqW4Hsht8oO0Pgf3MrLKH1_TdXZ5kfGNQXJCYUzg@mail.gmail.com> |
Of the various names mentioned, I like __set_owner__ the best - it may not be 100% accurate, but it gives me a better idea of what it is than any of the 'init_blah' names. Maybe __set_ownership__? 'Ownership' could certainly include 'what does my owner call me'. On 17 February 2016 at 12:56, Martin Teichmann <[email protected]> wrote: > Hi Sylvain, > > > My understanding is that the new `__set_owner__` method on the > descriptor exactly corresponds to the `class_init` in our base Descriptor > class, that is the part of the descriptor initialization that depends on > the class (while `instance_init` is the part of the initialization that > depends on the instance). However, it sometimes does a bit more than > setting the name of the owner, like in the case of the default > initializers. Hence I was wondering if the name was accurate. What do you > think about simply reusing `__class_init__`? > > There was some discussion on python-ideas about that name. > It is an extension to the descriptor protocol, which already has three > methods: __set__, __get__ and > __delete__. How should we name the new method? > > I personally don't like __class_init__, I think it is actually > misleading, as it is called on an object, not a class. > Originally, I had it called __init_descriptor__. Others considered > that misleading, because in the > new metaclass there is also an __init_subclass__, and one might think > that __init_descriptor__ is also > called on the initialized class, but it is called on the descriptor. > This is where the name __set_owner__ came > from, as in __get__ the parameter is called owner. But given that not > only the owner is set, but also the > name of the descriptor, __set_owner__ also might not be the best choice. > > Greetings > > Martin > _______________________________________________ > IPython-dev mailing list > [email protected] > https://mail.scipy.org/mailman/listinfo/ipython-dev > _______________________________________________ IPython-dev mailing list [email protected] https://mail.scipy.org/mailman/listinfo/ipython-dev