Delete dict and subdict items of some name

Hans Mulder hansmu at xs4all.nl
Tue Dec 18 05:31:41 EST 2012


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.


Hope this helps,

-- HansM




More information about the Python-list mailing list