title: How to scrub a dynamic python dictionary of specific keys?
body: <p>This one is just obtuse enough that no typical answer is bubbling to the top.</p>
  
  <p>The nature of the tool I'm working on dictates we use MongoDB to store 'settings' for about 25 different tools.  Each tool has it's own settings schema, so each document is different, but they're all stored in the same collection and edited on the same edit page which is drawn by json schema.</p>
  
  <p>Not knowing the schema of the dictionary, I'm struggling to figure out how to iterate and sanitize the data, specifically removing passwords.</p>
  
  <p>Given the following dictionary, and knowing that other dicts may have different schemas, how could I traverse every single item in the dict and create a copy, identical <em>except</em> with any key == "password" removed?</p>
  
  <p>So:</p>
  
  <pre><code>{
    "_enabled": true,
    "instances": [
      {
        "isdefault": true,
        "name": "dev",
        "password": "abc123",
        "url": "http://dev.example.com",
        "user": "buffy"
      },
      {
        "isdefault": false,
        "name": "prod",
        "password": "xxxxx",
        "url": "http://prod.example.com",
        "user": "spike"
      },
      {
        "isdefault": false,
        "name": "qa",
        "password": "dasddf",
        "url": "http://prod.example.com",
        "user": "willow"
      }
    ],
    "label": "MyServers"
  }
  </code></pre>
  
  <p>Should result in:</p>
  
  <pre><code>{
    "_enabled": true,
    "instances": [
      {
        "isdefault": true,
        "name": "dev",
        "url": "http://dev.example.com",
        "user": "buffy"
      },
      {
        "isdefault": false,
        "name": "prod",
        "url": "http://prod.example.com",
        "user": "spike"
      },
      {
        "isdefault": false,
        "name": "qa",
        "url": "http://prod.example.com",
        "user": "willow"
      }
    ],
    "label": "MyServers"
  }
  </code></pre>