Simple Problem but tough for me if i want it in linear time

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Mon Aug 16 19:17:41 EDT 2010


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



More information about the Python-list mailing list