title: Force creation of new memory object python
body: <p>How do I forcefully create a new object (in this case a dictionary) in python? The following should explain my problem:</p>
  
  <pre><code>&gt;&gt;&gt; class A():
  ...   def __init__(self, a={}):
  ...     self.a=a
  ... 
  &gt;&gt;&gt; id(A().a) == id(A().a)
  True
  
  &gt;&gt;&gt; class A():
  ...   def __init__(self, a=dict()):
  ...     self.a=a
  ... 
  &gt;&gt;&gt; id(A().a) == id(A().a)
  True
  
  &gt;&gt;&gt; class A():
  ...   def __init__(self, a={}):
  ...     self.a=copy.deepcopy(a)
  ... 
  &gt;&gt;&gt; id(A().a) == id(A().a)
  False
  </code></pre>
  
  <p>As you can see, the first two methods give me a pointer to the same empty dictionary, which means if I modify the dictionary in one object, it gets modified in the other. The third method seems so "unclean" to me. Is there an alternative? I know I could also use copy.copy, but I prefer deepcopy, for exactly these reasons.</p>