[Tutor] Aschenputtel problem

Christopher Arndt chris.arndt at web.de
Thu Sep 15 19:12:57 CEST 2005


Hi,

I wonder if there is a shorter form of the following idiom:

list1 = []
list2 = []
for item in original_list:
    if condition(item):
        list1.append(item)
    else:
        list2.append(item)

(optional step:)

original_list[:] = list1


I call this the "Aschenputtel" problem, because it is described by the famous
quote from the fairy tale as told by the Grimm brothers:

"Die guten ins Töpfchen, die schlechten ins Kröpfchen."

(The good ones in the pot, the bad ones in the crop)

Chris


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 278 bytes
Desc: OpenPGP digital signature
Url : http://mail.python.org/pipermail/tutor/attachments/20050915/d88c26f0/signature.pgp


More information about the Tutor mailing list