title: How do I build a __add__ method in a specific class in python?
body: <p>I defined a class named <code>DictList</code>. The <code>DictList</code> class represents a list of dict, with some keys appearing in more than one dict.It has one parameter: it matches one or more arguments( must be dictionary).</p>
  
  <pre><code>class DictList:
      def __init__(self,*args):
          self.n = args
  </code></pre>
  
  <p>Like :</p>
  
  <pre><code>A = DictList({'a':1, 'b':2, 'c':3}, {'c':5, 'd':7, 'e':16}, {'e':25, 'f':29)
  </code></pre>
  
  <p>Now I want to define a <strong>add</strong> method in this class. It will add two DictList together or add one DictList and one dictionary.</p>
  
  <p>Example:</p>
  
  <pre><code>&gt;&gt;&gt; A1 = DictList(dict(a=1,b=2), dict(b=12,c=13)) 
  &gt;&gt;&gt; A2 = DictList(dict(a='hi',b='hello'), dict(b='good',c='nice'))
  
  &gt;&gt;&gt; A1+A2 
  DictList({'a': 1, 'b': 2}, {'b': 12, 'c': 13}, {'a': 'hi', 'b': 'hello'}, {'b': 'good', 'c': 'nice'})
  
  &gt;&gt;&gt; A2 + A1
  DictList( {'a': 'hi', 'b': 'hello'}, {'b': good', 'c': 'nice'},{'a': 1, 'b': 2}, {'b': 12, 'c': 13})
  </code></pre>
  
  <p>My idea is to create a new DictList with a list of dictionaries that contains  all the dicts in the two DictLists or one DictList and one dict.</p>
  
  <pre><code>def __add__(self,new):
          if type(new) == DictList:
              print(DictList( all dicts from self and new ))
          if type(new) == dict:
              print(DictList(all dicts from self and new))        
  </code></pre>
  
  <p>But I don't know how to get every dict in the two DictList and put all of them into the new DictList.How can I do?</p>