Chris Rebert a écrit : (snip)
reduce(lambda x,y:x+y,({1:['b']*2,0:['a']}[z] for z in [1, 0, 0, 1]))['b', 'b', 'a', 'a', 'b', 'b']69 chars long (plus or minus how the input list is written).
You can save 4 more characters using tumple dispatch instead of dict dispatch:
reduce(lambda x,y : x+y, ((['a'], ['b']*2)[z] for z in [1, 0, 0, 1]))
Where's my golf trophy? ;)
golf ? Why golf ?-) -- http://mail.python.org/mailman/listinfo/python-list