Delete dict and subdict items of some name

Paul Rubin at nospam.invalid
Mon Dec 17 18:48:02 CET 2012

Gnarlodious <gnarlodious at> 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?


def unfav(x):
  if type(x) != dict: return x
  return dict((k,unfav(v)) for k,v in x.iteritems() if k != 'favicon')

More information about the Python-list mailing list