title: How can I make a class method return a new instance of itself?
body: <p>I have a python class which has a few lists and variables(initialized in <code>__init__</code>).</p>
  
  <p>I want to have a method which operates upon this particular instances data and returns a new instance(new data). In the end, this method should return a new instance with modified data while leaving the original instance's data intact.</p>
  
  <p>What is a pythonic way to do this?</p>
  
  <p>EDIT:</p>
  
  <p>I have a method in the class called <code>complement()</code> which modifies the data in a particular way. I would like to add a <code>__invert__()</code> method which returns an instance of the class with <code>complement()</code>ed data.</p>
  
  <p>Example: Suppose I have a class A.<br>
  a=A()<br>
  a.complement() would modify the data in instance a.<br>
  b = ~a would leave the data in instance a unchanged but b will contain complement()ed data.</p>