title: python OOP class method retaining variable. Weird scoping thing
body: <p>I have two classes, a main class which creates instances of my other class.</p>
  
  <pre><code>class Builder:
  
      def __init__(self, id):
          self.id = id
  
      def build_thing(self, main_ftr, main_attr, attrs = {}):
          # note the main ftr/attrs gets added to attrs no matter what
          attrs[main_ftr] = attrs.get(main_ftr, []) + [main_attr]
  
          return Thing(main_ftr, main_attr, attrs)
  
  class Thing:
  
      def __init__(self, main_ftr, main_attr, attrs):
          self.main_ftr = main_ftr
          self.main_attr = main_attr
          self.attrs = attrs
  </code></pre>
  
  <p>The issue I'm having has to do with the <code>attrs</code> dictionary that gets passed to the <code>Thing</code> class. The problem is that each time I use the <code>Builder</code> class to create a <code>Thing</code> class, the attrs argument retains it's previous values</p>
  
  <pre><code>b = Builder('123')
  
  t = b.build_thing('name', 'john')
  print(t.attrs) # {'name': ['john'] }
  
  # Goal is this creates a new "Thing" with only attrs = {'name':['mike']}
  t2 = b.build_thing('name', 'mike')
  print(t2.attrs) # {'name': ['john', 'mike']}
  </code></pre>
  
  <p>My Question is 2 part:</p>
  
  <p>Why is this happening?</p>
  
  <p>How do I fix it?</p>