[Tutor] Aschenputtel problem

Kent Johnson kent37 at tds.net
Thu Sep 15 23:29:36 CEST 2005

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 ]


for i in original:
  (condition(i) and list1 or list2).append(i)


More information about the Tutor mailing list