Tim Hochberg wrote: > Rewriting this using "distributed" adapters looks like this: > > >>> pprint = Protocol('pprint')
I suppose this means that Protocol('pprint') implies an interface like: class IPprint(Interface): def __call__(object): """print the pretty representation of the object""" Viewed from this perspective, RuleDispatch-style generic functions use the default implementation as the description of the interface, and only allow for callable interfaces. > >>> @pprint.when(object) > ... def pprint_obj(obj): > ... print repr(obj) > > >>> @pprint.when(list) > ... def pprint_list(obj): > ... print 'pretty(%r)' % obj > > > Pretty similar! Stealing the when decorator cleans up the use of > copy_reg.pickle rewrite a bit as well. I imagine that where these would > diverge is when there is more than one argument. > > > Regards, > > -tim > > > P.S., Here's Protocol. To save a few bytes I've stripped classic class > support. I suppose on the py3k list we don't have to apologize for ignoring classic classes ;) -- Ian Bicking / [EMAIL PROTECTED] / http://blog.ianbicking.org _______________________________________________ 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