title: Python class returning value
body: <p>I'm trying to create a class that returns a value, not self.</p>
  
  <p>I will show you an example comparing with a list:</p>
  
  <pre><code>&gt;&gt;&gt; l = list()
  &gt;&gt;&gt; print(l)
  []
  &gt;&gt;&gt; class MyClass:
  &gt;&gt;&gt;     pass
  
  &gt;&gt;&gt; mc = MyClass()
  &gt;&gt;&gt; print mc
  &lt;__main__.MyClass instance at 0x02892508&gt;
  </code></pre>
  
  <p>I need that MyClass returns a list, like <code>list()</code> does, not the instance info. I know that I can make a subclass of list. But is there a way to do it without subclassing?</p>
  
  <p>I want to imitate a list (or other objects):</p>
  
  <pre><code>&gt;&gt;&gt; l1 = list()
  &gt;&gt;&gt; l2 = list()
  &gt;&gt;&gt; l1
  []
  &gt;&gt;&gt; l2
  []
  &gt;&gt;&gt; l1 == l2
  True
  &gt;&gt;&gt; class MyClass():
  def __repr__(self):
      return '[]'
  
  
  &gt;&gt;&gt; m1 = MyClass()
  &gt;&gt;&gt; m2 = MyClass()
  &gt;&gt;&gt; m1
  []
  &gt;&gt;&gt; m2
  []
  &gt;&gt;&gt; m1 == m2
  False
  </code></pre>
  
  <p>Why is <code>m1 == m2</code> False? This is the question.</p>
  
  <p>I'm sorry if I don't respond to all of you. I'm trying all the solutions you give me. I cant use <code>def</code>, because I need to use functions like setitem, getitem, etc.</p>