parse list recurisively
andypu at zoho.com
andypu at zoho.com
Mon Sep 23 10:23:08 EDT 2013
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:
parsesb(lis[num],string,replacement)
if type(nam) == str: # do something
if nam == string: lis[num] = replacement
parsesb(sbxe1 ,'name', 'booooogyman')
print sbxe1
More information about the Python-list
mailing list