for , ordering

Andrew Koenig ark at
Thu Jun 6 19:51:53 CEST 2002

gabor> for obj1 in objects1:
gabor> objects2.append(obj2(obj1.x))

gabor> 1. isn't there a more elegant way to do this?

ark> Isn't this the same as saying

ark>         objects2 = objects1[:]

ark> ?  Am I missing something obvious?

The answer is yes:  I *am* missing something obvious:  I didn't
notice the obj2(obj1.x).  But why not

             objects2 = map(lambda x: obj2(obj1.x), objects1)

Andrew Koenig, ark at,

More information about the Python-list mailing list