Re: [Tutor] Getting list of attributes from list of objects

2009-09-10 Thread Douglas Philips
On or about 2009 Sep 10, at 11:36 AM, Serdar Tumgoren indited: I think a list comprehension might be the most compact way to accomplish what you're after: objcts = [a, b, c] titles = [obj.title for obj in objcts] That probably is the best form. For the sake of showing other options: from o

Re: [Tutor] Getting list of attributes from list of objects

2009-09-10 Thread Serdar Tumgoren
> I have the following list > > l= [ a, b, c] > > Where a,b,c are objects created from one class, e.g. each has title > attribute. > What I want to have is a list of titles, e.g. [a.title, b.title, c.title] > > Is there a quick way to do it? Or I should use loops (looping through each > element, an

Re: [Tutor] Getting list of attributes from list of objects

2009-09-10 Thread vince spicer
On Thu, Sep 10, 2009 at 8:51 AM, Oleg Oltar wrote: > Hi! > > I have the following list > > l= [ a, b, c] > > Where a,b,c are objects created from one class, e.g. each has title > attribute. > What I want to have is a list of titles, e.g. [a.title, b.title, c.title] > > Is there a quick way to do

[Tutor] Getting list of attributes from list of objects

2009-09-10 Thread Oleg Oltar
Hi! I have the following list l= [ a, b, c] Where a,b,c are objects created from one class, e.g. each has title attribute. What I want to have is a list of titles, e.g. [a.title, b.title, c.title] Is there a quick way to do it? Or I should use loops (looping through each element, and generating