title: How to get self object name from self method in Python
body: <p>I am trying to find a way to automatically print the object reference name with just a <code>print object</code>
  To be more specific.
  Lets say I have a class:</p>
  
  <pre><code>class A:
      def __init__(self):
          self.cards = []
  
      def __str__(self):
          # return a string representation of A
          return "A contains " ...
      ...
  </code></pre>
  
  <p>Now whenever i create an object</p>
  
  <pre><code>test = A()
  </code></pre>
  
  <p>and I use the <code>print test</code> it will get something like (do not mind the dots)</p>
  
  <pre><code>A contains ...
  </code></pre>
  
  <p>What I want to achieve is to automatically print the object reference name instead of the class name:</p>
  
  <pre><code>test contains ...
  </code></pre>
  
  <p>The <code>self.__class__</code> or <code>self.__name__</code> wont work since it returns a weird string like <code>&lt;class '__main__.A'&gt;</code>.</p>
  
  <p>How should <code>__str__</code> be implemented  to achieve this?
  Thanks in advance.</p>