title: Define a class with optional argument in Python
body: <pre><code>class class1():
      def setdata(self,value1, value2):
      self.data = value1+value2
  def display(self):
      print(self.data)
  </code></pre>
  
  <p>For the above code, when I use it. It will require exactly two arguments.</p>
  
  <pre><code>&gt;&gt;&gt;a = class1()
  &gt;&gt;&gt;a.setdata('123','456')
  </code></pre>
  
  <p>But what if I want to set a <code>default value</code> for <code>value2</code>, for exmaple, its(<code>value2</code>) default value is <code>'000'</code>. </p>
  
  <p>Next time when I use the class, I can either type </p>
  
  <pre><code>&gt;&gt;&gt;a = class1()
  &gt;&gt;&gt;a.setdata('123')
  </code></pre>
  
  <p><code>a.data</code> will be <code>'123000'</code></p>
  
  <p>Or I can type </p>
  
  <pre><code>&gt;&gt;&gt;a = class1()
  &gt;&gt;&gt;a.setdata('123','654')
  </code></pre>
  
  <p><code>a.data</code> will be <code>'123654'</code></p>
  
  <p>How to achieve this?
  Thanks very much!</p>