FW: list reduction

James Stroud jstroud at mbi.ucla.edu
Thu Mar 10 21:10:31 CET 2005


newlist = [y.cap for y in industrylist if y.cap < x]

On Thursday 10 March 2005 12:00 pm, Leeds, Mark wrote:
> I have a structure in python that I think is a list
>
> with elements .Cap and .Ticker
>
> where Cap is a float and Ticker is string.
>
>
>
> So, I reference things like
>
> industrylist[i].cap and industrylist[i].ticker
>
> and this works fine.
>
>
>
> What I want to do is reduce the list
>
> so that it only keeps elements of the list
>
> for which the cap is less than x where x is known ?
>
>
>
> I think I need to use filter and lambda but
>
> i've looked in the documentation
>
> and I haven't been able to figure out
>
> how to use it.
>
>
>
> Apologies if this is a bad question.
>
>
>
>                                     Thanks

-- 
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095



More information about the Python-list mailing list