[Python-Dev] PEP 487 vs 422 (dynamic class decoration)
Eric Snow
ericsnowcurrently at gmail.com
Mon Apr 6 17:22:23 CEST 2015
On Sat, Apr 4, 2015 at 6:40 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Eric Snow wrote:
>>
>> I've felt for a long time that it would be helpful in some situations
>> to have a reverse descriptor protocol.
>
> Can you elaborate on what you mean by that?
Sure. It's more python-ideas territory (I posted about it a few years
back). The idea is to allow an object the opportunity to handle being
bound to a name. So if a type defines __bound__ (or similar) then it
will be called for the instance being bound to a name:
type(obj).__bound__(obj, name). There would also be an __unbound__,
but that is less of an issue here.
I'm still not convinced such a reverse descriptor protocol is
practical as a general approach (though no less than the current
descriptor protocol). However, I do see a distinct correspondence
with the "__post_process__" method being considered here. So I wanted
to point out the possibility of a more general approach for the sake
of its impact on the name and semantics of a descriptor post-process
method. While I expect __post_process__ would be called at a
different place than __bound__, the responsibility of both would still
be identical.
-eric
More information about the Python-Dev
mailing list