[Python-3000] Discussions with no PEPs (original) (raw)

Phillip J. Eby pje at telecommunity.com
Tue Mar 13 17:12:32 CET 2007


At 11:51 AM 3/13/2007 -0400, Barry Warsaw wrote:

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

On Mar 13, 2007, at 11:06 AM, Phillip J. Eby wrote: > I prefer to think of adaptation as being a way to provide a > namespace for generic functions. :) > > See http://mail.python.org/pipermail/python-3000/2006-November/ > 004717.html for an implementation of this idea. Basically, you > define an interface by creating generic functions in the body of an > 'Interface' subclass... and the resulting Interface can then be > used to adapt any object to it. The 26 lines of code I gave can be > used are not specific to any particular generic function > implementation, so they could be used with simplegeneric, > RuleDispatch, PEAK-Rules, Guido's prototype, or anything else you > might come up with. Interesting, and thanks for the links. I'm not 100% I got it all on the first reading, but I think I see where you're going. I'm glad to see my question is just plowing the same ground for the third tiem (at least :). One thing is still missing though, and that's the documentation aspects of something like zope.interfaces. You could say that generics.interfaces could just use docstrings, which is fine for methods, but how would you document attributes in a discoverable way?

property() is one way, of course, but the implementation sketched in that email supports any sort of descriptor you want. The AdaptingDescriptor should probably support set and delete as well, but you see the general idea.



More information about the Python-3000 mailing list