Re: parse list recurisively

2013-09-23 Thread andypu
i have a list and i want to search for a certain string and replace it. i think i got it now... sbxe1 = list([['type','ter','lala'],'name']) def parsesb(lis, string, replacement): for num, nam in enumerate (lis): if type(nam) == list: parse

Re: parse list recurisively

2013-09-23 Thread Oscar Benjamin
On 23 September 2013 13:53, wrote: > Hello, > > i use a load of lists and often i dont know how deep it is, how can i parse > that lists elegantly (without a bunch of for loops) I don't really understand what you mean. Can you show some code that illustrates what you're doing? http://sscce.org

Re: parse list recurisively

2013-09-23 Thread andypu
thanks i was not able to figure it out some days before but now i think i can do it myself: a nice function that searches a string in a list. def parsesb(lis, string): print lis for num, nam in enumerate (lis): print num, nam if type(nam) == list:

Re: parse list recurisively

2013-09-23 Thread Chris Angelico
On Mon, Sep 23, 2013 at 10:53 PM, wrote: > Hello, > > i use a load of lists and often i dont know how deep it is, how can i parse > that lists elegantly (without a bunch of for loops) You can write a function that calls itself - that's what "recursive" usually means in programming. Start with t

parse list recurisively

2013-09-23 Thread andypu
Hello, i use a load of lists and often i dont know how deep it is, how can i parse that lists elegantly (without a bunch of for loops) -- https://mail.python.org/mailman/listinfo/python-list