Re: Delete dict and subdict items of some name

2012-12-18 Thread Hans Mulder
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

Re: Delete dict and subdict items of some name

2012-12-18 Thread Gnarlodious
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:

Re: Delete dict and subdict items of some name

2012-12-18 Thread Terry Reedy
On 12/18/2012 10:27 AM, Gnarlodious wrote: On Tuesday, December 18, 2012 3:31:41 AM UTC-7, Hans Mulder wrote: On 18/12/12 06:30:48, Gnarlodious wrote: from plistlib import readPlist I do not see this used below. def explicate(listDicts): for dict in listDicts: if

Delete dict and subdict items of some name

2012-12-17 Thread Gnarlodious
Hello. What I want to do is delete every dictionary key/value of the name 'Favicon' regardless of depth in subdicts, of which there are many. What is the best way to do it? -- Gnarlie -- http://mail.python.org/mailman/listinfo/python-list

Re: Delete dict and subdict items of some name

2012-12-17 Thread Oscar Benjamin
On 17 December 2012 17:27, Gnarlodious gnarlodi...@gmail.com wrote: Hello. What I want to do is delete every dictionary key/value of the name 'Favicon' regardless of depth in subdicts, of which there are many. What is the best way to do it? You might need to be a bit clearer about what you

Re: Delete dict and subdict items of some name

2012-12-17 Thread Mitya Sirenef
On 12/17/2012 12:27 PM, Gnarlodious wrote: Hello. What I want to do is delete every dictionary key/value of the name 'Favicon' regardless of depth in subdicts, of which there are many. What is the best way to do it? -- Gnarlie Something like this should work: def delkey(d, key): if

Re: Delete dict and subdict items of some name

2012-12-17 Thread Paul Rubin
Gnarlodious gnarlodi...@gmail.com writes: Hello. What I want to do is delete every dictionary key/value of the name 'Favicon' regardless of depth in subdicts, of which there are many. What is the best way to do it? Untested: def unfav(x): if type(x) != dict: return x return

Re: Delete dict and subdict items of some name

2012-12-17 Thread Dave Angel
On 12/17/2012 12:27 PM, Gnarlodious wrote: Hello. What I want to do is delete every dictionary key/value of the name 'Favicon' regardless of depth in subdicts, of which there are many. What is the best way to do it? -- Gnarlie I would write a recursive function that accepts a dict. In that

Re: Delete dict and subdict items of some name

2012-12-17 Thread Tim Chase
On 12/17/12 11:43, Mitya Sirenef wrote: On 12/17/2012 12:27 PM, Gnarlodious wrote: Hello. What I want to do is delete every dictionary key/value of the name 'Favicon' regardless of depth in subdicts, of which there are many. What is the best way to do it? Something like this should work:

Re: Delete dict and subdict items of some name

2012-12-17 Thread Mitya Sirenef
On 12/17/2012 01:30 PM, Tim Chase wrote: On 12/17/12 11:43, Mitya Sirenef wrote: On 12/17/2012 12:27 PM, Gnarlodious wrote: Hello. What I want to do is delete every dictionary key/value of the name 'Favicon' regardless of depth in subdicts, of which there are many. What is the best way to do

Re: Delete dict and subdict items of some name

2012-12-17 Thread Chris Angelico
On Tue, Dec 18, 2012 at 8:33 AM, Mitya Sirenef msire...@lightbird.net wrote: On 12/17/2012 01:30 PM, Tim Chase wrote: On 12/17/12 11:43, Mitya Sirenef wrote: On 12/17/2012 12:27 PM, Gnarlodious wrote: Hello. What I want to do is delete every dictionary key/value of the name 'Favicon'

Re: Delete dict and subdict items of some name

2012-12-17 Thread Dave Angel
On 12/17/2012 04:33 PM, Mitya Sirenef wrote: On 12/17/2012 01:30 PM, Tim Chase wrote: On 12/17/12 11:43, Mitya Sirenef wrote: On 12/17/2012 12:27 PM, Gnarlodious wrote: Hello. What I want to do is delete every dictionary key/value of the name 'Favicon' regardless of depth in subdicts, of

Re: Delete dict and subdict items of some name

2012-12-17 Thread MRAB
On 2012-12-17 22:00, Dave Angel wrote: On 12/17/2012 04:33 PM, Mitya Sirenef wrote: On 12/17/2012 01:30 PM, Tim Chase wrote: On 12/17/12 11:43, Mitya Sirenef wrote: On 12/17/2012 12:27 PM, Gnarlodious wrote: Hello. What I want to do is delete every dictionary key/value of the name 'Favicon'

Re: Delete dict and subdict items of some name

2012-12-17 Thread Steven D'Aprano
On Mon, 17 Dec 2012 09:27:48 -0800, Gnarlodious wrote: Hello. What I want to do is delete every dictionary key/value of the name 'Favicon' regardless of depth in subdicts, of which there are many. What is the best way to do it? Firstly, you should assume we know what you are talking about,

Re: Delete dict and subdict items of some name

2012-12-17 Thread Oscar Benjamin
On 17 December 2012 23:44, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On 17 December 2012 23:08, MRAB pyt...@mrabarnett.plus.com wrote: Wouldn't a set of the id of the visited objects work? Of course it would. This is just a tree search. Here's a depth-first-search function: def

Re: Delete dict and subdict items of some name

2012-12-17 Thread Mitya Sirenef
On 12/17/2012 05:00 PM, Dave Angel wrote: On 12/17/2012 04:33 PM, Mitya Sirenef wrote: On 12/17/2012 01:30 PM, Tim Chase wrote: On 12/17/12 11:43, Mitya Sirenef wrote: On 12/17/2012 12:27 PM, Gnarlodious wrote: Hello. What I want to do is delete every dictionary key/value of the name

Re: Delete dict and subdict items of some name

2012-12-17 Thread Oscar Benjamin
On 17 December 2012 23:08, MRAB pyt...@mrabarnett.plus.com wrote: On 2012-12-17 22:00, Dave Angel wrote: On 12/17/2012 04:33 PM, Mitya Sirenef wrote: On 12/17/2012 01:30 PM, Tim Chase wrote: On 12/17/12 11:43, Mitya Sirenef wrote: On 12/17/2012 12:27 PM, Gnarlodious wrote: Hello. What I

Re: Delete dict and subdict items of some name

2012-12-17 Thread Dave Angel
On 12/17/2012 06:08 PM, MRAB wrote: On 2012-12-17 22:00, Dave Angel wrote: On 12/17/2012 04:33 PM, Mitya Sirenef wrote: On 12/17/2012 01:30 PM, Tim Chase wrote: On 12/17/12 11:43, Mitya Sirenef wrote: On 12/17/2012 12:27 PM, Gnarlodious wrote: Hello. What I want to do is delete every

Re: Delete dict and subdict items of some name

2012-12-17 Thread Gnarlodious
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