Alan Gauld wrote: >>I wonder if there is a shorter form of the following idiom: > > > Bearing in mind that shorter is not necessarily better... > > [condition(i) and list1.append(i) or list2.append(i) for i in > original]
Hmm, no, this will always evaluate list2.append(i) because the value of list1.append(i) is None. You could use [ (condition(i) and list1 or list2).append(i) for i in original ] or for i in original: (condition(i) and list1 or list2).append(i) Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor