title: Pythonic alternative to (nested) dictionaries with the same keys?
body: <p>I find myself avoiding dictionaries because, often, nearly half their code is duplicate.  I typically do this in nested dictionaries, where all sub-dictionaries contain the same keys, but different values.</p>
  
  <p>I manually create a large parent dictionary, where each key contains a nested dictionary, to be used in external modules.  The nested dictionaries all use the same keys to define configuration parameters.  This usage is explicit and works but it feels foolish to retype or copy/paste the keys for each nested dictionary I create manually.  I am not overly concerned about optimizing memory or performance, just wondering if I should be doing this another, more Pythonic way. </p>
  
  <p>As a trivial example and pattern often seen:</p>
  
  <pre><code>people_dict = {
      "Charles Lindberg": {"address": "123 St.", 
                           "famous": True}, 
      "Me": {"address": "456 St.",
             "famous": False}
      }
  
  &gt;&gt;&gt;people_dict["Charles Lindberg"]["address"]
  "123 St."
  </code></pre>
  
  <p>While the dictionary enables explicit code, it is tedious and error prone to define nested dictionaries with duplicate keys.  In this example, half the nested dictionary is code duplicate code common to all the nested dictionaries.
  I have tried using tuples to eliminate duplicate keys but find this leads to fragile code - any change in position (rather than a dictionary key) fails.  This also leads to code that is not explicit and hard to follow.</p>
  
  <pre><code>people_dict = {
          "Charles Lindberg": ("123 St.", True), 
          "Me": ("456 St.", False),
          }    
  
  &gt;&gt;&gt;people_dict["Charles Lindberg"][0]
  "123 St."
  </code></pre>
  
  <p>Instead, I write a class to encapsulate the same information:  This 
  successfully reduces duplicate code...</p>
  
  <pre><code>class Person(object):
      def __init__(self, address, famous=False):
          self.address = address
          self.famous = famous
  
  people_dict = [
      "Charles Lindberg": Person("123 St.", famous=False), 
      "Me": Person("456 St."), 
      ]
  
  &gt;&gt;&gt;people_dict["Charles Lindberg"].address
  "123 St." 
  </code></pre>
  
  <p>Creating a class seems a little overkill... The standard data types seem too basic...</p>
  
  <h2>I imagine there's better way to do this in Python, without having to write your own class?</h2>
  
  <h2>What is the best way to avoid duplicate code when creating nested dictionaries with common keys?</h2>