for , ordering

Andrew Koenig ark at research.att.com
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 research.att.com, http://www.research.att.com/info/ark



More information about the Python-list mailing list