On Mon, 2010-08-16 at 23:17 +0000, Steven D'Aprano wrote: > On Mon, 16 Aug 2010 20:40:52 +0200, Frederic Rentsch wrote: > > > How about > > > >>>> [obj for obj in dataList if obj.number == 100] > > > > That should create a list of all objects whose .number is 100. No need > > to cycle through a loop. > > What do you think the list comprehension does, if not cycle through a > loop? > > > -- > Steven
What I think is that list comprehensions cycle through a loop a lot faster than a coded loop (for n in ...:). As at the time of my post only coded loops had been proposed and the OP was concerned about speed, I thought I'd propose a list comprehension. I guess my explanation was poorly phrased. Thanks for the reminder. Frederic -- http://mail.python.org/mailman/listinfo/python-list