[PEAK] Use cases for the priority feature

Christoph Zwerschke cito at online.de
Wed Aug 18 14:40:57 EDT 2010


Am 18.08.2010 01:56 schrieb P.J. Eby:
 > At 12:37 AM 8/18/2010 +0200, Christoph Zwerschke wrote:
>> Granted, that should work. But it looks a bit overly complicated
>> to me, because you have to work with functions getters here,
>> whereas with the priority parameter you could use the actual
>> functions and spare some of the overhead.
 >
 > Here's Yet Another Way To Do It, btw:
 >
 > ...
 > def call_highest_priority(results):
 > for quality, method in sorted(results, key=operator.itemgetter(0)):
 >     return method()

That's good, but it gives the method with the minimum quality. Why not:

def call_highest_priority(results):
     return max(results, key=itemgetter(0))[1]()

It's still too much decoration overhead for me, though.

I liked the approach with the "quality < x" condition better. The only 
disadvantage I see is that it requires all methods to receive that 
parameter even though the methods themselves don't actually need it.

-- Christoph


More information about the PEAK mailing list