title: Check if an object has been instantiated
body: <p>I keep running into an issue where I have to check whether an object has been instantiated for a class or whether a variable was created. </p>
  
  <p>If, for example, the variable <code>frog</code> was never created</p>
  
  <pre><code>bool(frog)
  </code></pre>
  
  <p>I get an undefined error -- I probably should have used <code>type(frog)</code> there but same error an <code>bool(frog)</code> sounds funnier. Instead, if I write</p>
  
  <pre><code>'frog' in dir()
  </code></pre>
  
  <p>I'll get <code>False</code> as output. That's fine, but more commonly I run into an issue with objects where I'm conditionally instantiating them and I don't know what their name is (like they're in a list). Consider an object from</p>
  
  <pre><code>class beatle(object):
  
      def __init__(self, name):
          self.name = name
  
  b1 = beatle('Ringo')
  </code></pre>
  
  <p>Now, if this was happening only on certain occasions in a far away part of my code, and I didn't know the <code>object</code> was called <code>b1</code>, how could I check if an instance of <code>beatle</code> ever occurred? If I check <code>dir()</code>, I can't tell by the names if any member <code>dir()</code> is actually a beatle -- or possibly a list of beatles. The problem for me is that <code>dir()</code> is a list of <code>&lt;class str&gt;</code>, so I don't think it can provide what I need. I thought about just adding some <code>bool</code> type indicator in any conditional where the object is created but that seems too "hard-codish". </p>
  
  <hr>
  
  <p>EDIT: There was a big edit here because I've been improving my coding since my last post, and I'm trying to avoid a ban from question asking, so  I apologize if this obfuscates anyone's original comments.</p>