Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.055 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'function,': 0.07; 'python': 0.09; 'accepts': 0.09; 'exists,': 0.09; 'cc:addr:python- list': 0.10; 'aiming': 0.16; 'at.': 0.16; 'key/value': 0.16; 'pairs,': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'bit': 0.21; 'regardless': 0.21; 'work,': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'depth': 0.29; 'dictionary': 0.29; 'subject:some': 0.29; 'function': 0.30; 'version': 0.34; 'pm,': 0.35; "won't": 0.35; 'there': 0.35; 'subject:: ': 0.38; 'delete': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'remove': 0.61; 'information,': 0.63; 'more': 0.63; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'yourself': 0.77; 'dict,': 0.84; 'dict.': 0.84; 'received:74.208.4.194': 0.84; 'try,': 0.84; 'to:none': 0.93 Date: Mon, 17 Dec 2012 12:50:57 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 CC: python-list@python.org Subject: Re: Delete dict and subdict items of some name References: <943dbf16-1cd1-4844-a666-d8863f5941f8@googlegroups.com> In-Reply-To: <943dbf16-1cd1-4844-a666-d8863f5941f8@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:EXF7CHbc9yHOrO5t8eTvOLksh+MX2ljf3gBywNhPi5C UbZ+gR3Gq8Iq6XLtd0mqeHSCxg07AhhpJ4dWbFVy3RVQch00+x 23WNHiYFhKg8M2QJVqoNYvxM8LWlTfdiBqND8CJtccxxP2TCrC ejxBHFHF0r5lPucbbBjd9QvTPH5oRXdly2HPPO7nRbWe4zv+uT p1dA/7vKVJVsds9GG58ai1ntt4wgLZBTpwu3JSJMIKB8Osp+sn Y4uf5Vr/NoUGPOEWZSVR3ltyMCTERXc1sV4Oa5Rx3YoKt7l7b8 JIQF1MTuNAk6Sg00+StO5F+PMXYEatGehY3/2sEEMLltG2Izw= = X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1355766682 news.xs4all.nl 6865 [2001:888:2000:d::a6]:36909 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35000 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 function, if a key "Favicon" exists, then remove it. Then loop through the dictionary key/value pairs, and for any value that's an instance of dict, call yourself recursively. Give it a try, and if it won't work, supply us with a bit more information, starting with a sample dict, and the python version you're aiming at. -- DaveA