title: Multiple constructor with Python
body: <p>I have a class A that can be generated from two different ways.</p>
  
  <ul>
  <li>a = A(path_to_xml_file)</li>
  <li>a = A(listA, listB)</li>
  </ul>
  
  <p>The first method has file path as an input to parse from XML file to get listA, and listB. The second method is given two lists.</p>
  
  <p>I can think of two ways to implement multiple constructor. What do you think? What method normally Python guys use for this case?</p>
  
  <h3>Check the type</h3>
  
  <pre><code>class A():
      def __init__(self, arg1, arg2 = None):
          if isinstance(arg1, str): 
              ...
          elif isinstance(arg1, list):
              ...
  
  a = A("abc")
  b = A([1,2,3],[4,5,6])
  </code></pre>
  
  <h3>Make different builders</h3>
  
  <pre><code>class A2():
      def __init__(self):
          pass
      def genFromPath(self, path):
          ...
      def genFromList(self, list1, list2):
          ...
  a = A2()
  a.genFromPath("abc")
  b = A2()
  b.genFromList([1,2,3],[4,5,6])
  </code></pre>