Greg Ewing wrote: > Paul Moore wrote: >>The "traditional" solution, __index__, requires co-operation >>from all classes that want to support the new protocol. Adaptation >>doesn't - it can be added externally. > > I don't follow that. Adaptation only works if the > framework author has thought to make an adaptation > call at the point where it's needed.
For this use case, you're right, but Paul was talking about co-operation from the inputs, not the framework. If the framework adapted something to IIndex and the framework user wanted to pass something that didn't conform to IIndex and didn't have an adapter available, the user could provide one. > If I, as the framework author, were the one that > benefited from making adaptation calls, then I > could leave them until I needed them. But that's > not how it works -- it's *users* of my framework > that benefit, and they're not in a position to > add them to my framework. As the framework author you want to increase the benefit to your users, so you find ways to do that. Those ways include adding adaptation where it creates benefits. > So I have to think > ahead and try to anticipate what adaptations > other people might want my code to make. Just as you have to think ahead and anticipate what functionality other people might want. Adaptation isn't magic; it's still part of iterative design improvement. -- Benji York _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com