doh. ok, so, recursion is just functional programming sugar for a loop. def get_As(L): checking = [elem for elem in L if isinstance(elem, list)] # the equivalent of elem in recursion all_As = [elem for elem in L if isinstance(elem, A)] while checking: new_checking = [] # all lists in all lists in checking for sub_L in checking: for elem in sub_L: if isinstance(elem, A): all_As.append(elem) elif isinstance(elem, list): new_checking.append(elem) checking = new_checking return all_As
yomgui wrote: > I forgot the most important, I am looking for a non recursive method. > > thanks > > yomgui > > yomgui wrote: > > > > Hi, > > > > I have a list of data (type A) > > my list can includes element of type A or a lists, > > these list can includes element of type A or a lists, and so on ... > > > > is there a simple way to obtain a single list of all the elemets > > of type A ? > > > > thanks > > > > yomgui -- http://mail.python.org/mailman/listinfo/python-list