title: How do you get all classes defined in a module but not imported?
body: <p>I've already seen the following question but it doesn't quite get me where I want: <a href="https://stackoverflow.com/questions/1796180/python-get-list-of-all-classes-within-current-module">How can I get a list of all classes within current module in Python?</a></p>
  
  <p>In particular, I do not want classes that are imported, e.g. if I had the following module:</p>
  
  <pre><code>from my.namespace import MyBaseClass
  from somewhere.else import SomeOtherClass
  
  class NewClass(MyBaseClass):
      pass
  
  class AnotherClass(MyBaseClass):
      pass
  
  class YetAnotherClass(MyBaseClass):
      pass
  </code></pre>
  
  <p>If I use <code>clsmembers = inspect.getmembers(sys.modules[__name__], inspect.isclass)</code> like the accepted answer in the linked question suggests, it would return <code>MyBaseClass</code> and <code>SomeOtherClass</code> in addition to the 3 defined in this module.</p>
  
  <p>How can I get only <code>NewClass</code>, <code>AnotherClass</code> and <code>YetAnotherClass</code>?</p>