Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54642
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-09-23 07:23 -0700 |
| References | <9b5d915b-3750-43ab-9691-1b1445332c43@googlegroups.com> <mailman.264.1379941213.18130.python-list@python.org> <9f139899-334b-4885-bc5b-09860f511f82@googlegroups.com> |
| Message-ID | <0629f7b7-4416-4225-bf7b-9d53b02e9e8d@googlegroups.com> (permalink) |
| Subject | Re: parse list recurisively |
| From | andypu@zoho.com |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
parse list recurisively andypu@zoho.com - 2013-09-23 05:53 -0700
Re: parse list recurisively Chris Angelico <rosuav@gmail.com> - 2013-09-23 23:00 +1000
Re: parse list recurisively andypu@zoho.com - 2013-09-23 07:07 -0700
Re: parse list recurisively andypu@zoho.com - 2013-09-23 07:23 -0700
Re: parse list recurisively Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-09-23 15:10 +0100
csiph-web