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 '

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"

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): > f

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 d

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

Re: Delete dict and subdict items of some name

2012-12-17 Thread Oscar Benjamin
On 17 December 2012 23:08, 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 wan

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 'Favicon

Re: Delete dict and subdict items of some name

2012-12-17 Thread Oscar Benjamin
On 17 December 2012 23:44, Oscar Benjamin wrote: > On 17 December 2012 23:08, MRAB 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 dfs(root, childfunc, func): > '''depth first

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 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' r

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 subd

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 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' regar

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 it

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

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

Re: Delete dict and subdict items of some name

2012-12-17 Thread Paul Rubin
Gnarlodious 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 dict((k,unfav(v)) for k,v in x.it

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 isin

Re: Delete dict and subdict items of some name

2012-12-17 Thread Oscar Benjamin
On 17 December 2012 17:27, 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? You might need to be a bit clearer about what you mean by subdicts. I

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