title: Formatting output string for __str__ in python3 class
body: <p>so I just finished up my first semester of Java and am trying to convert some of our projects into python code. We have a PetRecord class that needs to have a name (str), age (double), and weight (double). The project required creating getters and setters for all of these, as well as a toString. </p>
  
  <p>I found an example <code>__str__</code> method being used that allows a python object's attributes to be printed to screen just by <code>print(object_name)</code>. I'm not sure why my formatting isn't working properly. If someone could enlighten my on why it's throwing: </p>
  
  <pre><code>Traceback (most recent call last):
    File "PetRecord.py", line 92, in &lt;module&gt;
      print(TestPet)
    File "PetRecord.py", line 49, in __str__
      return('Name: {self.__name} \nAge: {self.__age} \nWeight:{self.__weight}').format(**self.__dict__) # this is printing literally 
  KeyError: 'self'
  </code></pre>
  
  <p>The code itself (changed the line formatting a bit for this post):</p>
  
  <pre><code>class PetRecord(object):
    '''
    All pets come with names, age and weight
    '''
    def __init__(self, name='No Name', age=-1.0,
                 weight=-1.0):
      # data fields
      self.__name = name
      self.__age = age
      self.__weight = weight
  
    def __str__(self):
      # toString()  
      return('Name: {self.__name} \nAge: {self.__age} 
            \nWeight:{self.__weight}').format(
            **self.__dict__) # this is printing literally 
  </code></pre>
  
  <p>Any help at all would be greatly appreciated. </p>