[Python-Dev] PEP 487 vs 422 (dynamic class decoration) (original) (raw)

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