[IPython-dev] Metaclasses in traitlets and PEP 487
takowl at gmail.com
Wed Feb 17 08:51:14 EST 2016
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 <lkb.teichmann at gmail.com>
> 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.
> IPython-dev mailing list
> IPython-dev at scipy.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev