Searching for most pythonic/least stupid way to do something simple

david jensen dmj.ccc at gmail.com
Tue Mar 16 17:54:57 CET 2010


of course, changing nn's to:
def getOutcomes(myList=[2,5,8,3,5]):
   low_id = int(myList[0]>myList[1])
   amountToShare = 2*myList[low_id]
   remainder = myList[not low_id]-myList[low_id]
   tail=list(myList[2:])
   outcomes = [[amountToShare*perc, remainder+amountToShare*(1-perc)]+
tail for perc in (1.0, 0.75, 0.5, 0.25, 0.0)] if not low_id else
[[remainder+amountToShare*perc, amountToShare*(1-perc)]+ tail for perc
in (1.0, 0.75, 0.5, 0.25, 0.0)]
   return outcomes


works, just hides the ugliness in a more compact form



More information about the Python-list mailing list