Delete dict and subdict items of some name
Gnarlodious
gnarlodious at gmail.com
Tue Dec 18 10:27:43 EST 2012
On Tuesday, December 18, 2012 3:31:41 AM UTC-7, Hans Mulder wrote:
> On 18/12/12 06:30:48, Gnarlodious wrote:
>
> > This problem is solved, I am so proud of myself for figuring it out!
>
> > After reading some of these ideas I discovered the plist is really
>
> > lists underneath any "Children" key:
>
> >
>
> >
>
> > from plistlib import readPlist
>
> >
>
> > def explicate(listDicts):
>
> > for dict in listDicts:
>
> > if 'FavIcon' in dict:
>
> > del dict['FavIcon']
>
> > if 'Children' in dict:
>
> > dict['Children']=explicate(dict['Children'])
>
> > return listDicts
>
> It would be more Pythonic to return None, to indicate that you've
> changed the list in situ.
>
> Since None is the default return value, this means you can leave
> out the return statement.
But then it only operates on the outer layer, inner layers might get processed but not written. Unless I don't understand what you're saying.
--Gnarlie
More information about the Python-list
mailing list