title: Unable to get a reference to a certain object inside another class
body: <p>So i'm trying to create an application using python and kivy. I have created a class that acts as my database here:</p>
  <pre><code>class database():
      Links = ['www.example.com', 'www.youtube.com']
  
      #Adds the new link to the Links list and then saves the list at Links.txt
      def SaveLinks(self, L):
          try:
              self.Links.append(L)
              with open(&quot;Links.txt&quot;, &quot;w&quot;) as f:
                  json.dump(self.Links, f)
                  f.close()
              return 0
          except:
              print(&quot;Error saving the data&quot;)
              return -1
  </code></pre>
  <p>But i need some screens to be able to interact with the database class so that i can add data to the list. So after doing some research, i found a possible(?) way to do it using the garbage collector library.  I created a function inside a screen's class and bound a button from it to the Save function:</p>
  <pre><code>class AddLinksScreen(Screen):
  
      def Save(self):
          for obj in gc.get_objects():
              if isinstance(obj, database):
                  obj.SaveLinks(self.ids.TextI.text) 
  </code></pre>
  <p>When i enter text in the textinput and and press the button, i get the following error:</p>
  <pre><code>Exception has occurred: ReferenceError
  weakly-referenced object no longer exists
  </code></pre>
  <p>So it's obvious that i'm doing something the wrong way. If i just bypass the gc and enter the object's name i have no problem. But the thing is that i want to be able to find it without knowing the name of the object. This is what i tried and it worked:</p>
  <pre><code>class AddLinksScreen(Screen):
  
      def Save(self):
          Databaseobj1.AddLink(self.ids.TextI.text)
  </code></pre>
  <p>Databaseobj1 is a class instance of the <code>database()</code> class</p>
  <p>Any help would be really appreciated</p>