title: Python: Referring to any created object with __init__
body: <p>Am building a program in which i use the constructor method in a class.
  My method looks like this:</p>
  
  <pre><code>class Myclass:
      population = 0
      def __init__(self, var1, var2, var3):
          Myclass.population +=1
          self.var1 = var1
          self.var2 = var2
          self.var3 = var3
          popFile = open('pop.txt', 'wt')
          popFile.write('population = ' + str(int(Myclass.population)))
          print('blablabla')
          print('again blablabla')
          popFile.close()
          pliada = (var1, var2, var3)
          outFile = open('prog.txt', 'at')
          outFile.write(str(pliada) + '\n')
          outFile.close()
  </code></pre>
  
  <p>My problem is that in the above</p>
  
  <pre><code>outFile.write(str(pliada) + '\n')
  </code></pre>
  
  <p>I want to save apart from the tuple, the objects name! What else should I add inside the write() func?</p>
  
  <p>For example when I run the program, i type:</p>
  
  <pre><code>First = Myclass('firstvar','secondvar','thirdvar')
  </code></pre>
  
  <p>and when i use</p>
  
  <pre><code>print(First)
  </code></pre>
  
  <p>it only prints the above tuple. When I open prog.txt, again its only the tuple there.
  How can I refer to each object's name (am constructing) so that instead of saving ('firstvar','secondvar',thirdvar') my program will save First ('firstvar','secondvar',thirdvar'), where First is the var I entered to the program?</p>
  
  <p>Thanks</p>