>> [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 ]
Oops! Good point, which emphasises the point about shorter not necessarily being better! My personal approach would be two separate comprehensions(*) which keeps the intent very clear and keeps it short at the expense of iterating the original list twice. (*) Or you could use the filter funtion twice if you want to make the intent even more explicit... Alan G. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor