Re: List comprehension returning subclassed list type?

2007-03-25 Thread Pierre Quentel
On 25 mar, 08:43, bullockbefriending bard [EMAIL PROTECTED] wrote: Given: class Z(object): various defs, etc. class ZList(list): various defs, etc. i would like to be able to replace z_list = ZList() for y in list_of_objects_of_class_Y: z_list.append(y) with something

Re: List comprehension returning subclassed list type?

2007-03-25 Thread Steven D'Aprano
On Sat, 24 Mar 2007 23:43:10 -0700, bullockbefriending bard wrote: z_list = [Z(y.var1, y.var2,..) for y in list_of_objects_of_class_Y] Of course this just gives me a plain list and no access to the methodsof z_list. List comprehensions give you a list. If you want to convert that list into

Re: List comprehension returning subclassed list type?

2007-03-25 Thread bullockbefriending bard
Thanks! I went with extend and generator expression as I *am* dealing with rather a lot of data. Now I think I'm going to go on a little hunt through my code looking for more places where I should replace list comprehensions with generator expressions - bit of a newbie here. On Mar 25, 3:57 pm,

List comprehension returning subclassed list type?

2007-03-24 Thread bullockbefriending bard
Given: class Z(object): various defs, etc. class ZList(list): various defs, etc. i would like to be able to replace z_list = ZList() for y in list_of_objects_of_class_Y: z_list.append(y) with something like this: z_list = [Z(y.var1, y.var2,..) for y in

Re: List comprehension returning subclassed list type?

2007-03-24 Thread Shane Geiger
To the best of my understanding, this answers your question: iterable A container object capable of returning its members one at a time. Examples of iterables include all sequence types (such as list, str, and tuple) and some non-sequence types like dict and