title: Python -- Check if object is instance of any class from a certain module
body: <p>Need a way to check if an object is an instance of any class in some particular module.</p>
  
  <p>I know I can do it by explicitly importing every class from that module and checking with a tuple:</p>
  
  <pre><code>from my_module import ClassOne, ClassTwo
  
  &gt;&gt;&gt; isinstance(my_obj, (ClassOne, ClassTwo))
  True
  </code></pre>
  
  <p>But in reality, the module I'm importing from has a TON of classes in it, and seems needlessly verbose to import them all explicitly, use them to build a huge tuple, and type check against it.  I've tried a few things to avoid this:</p>
  
  <pre><code>import my_module
  
  # Test my_obj against the module itself
  &gt;&gt;&gt; isinstance(my_obj, my_module)
  TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
  
  # Try to test against a wildcard attribute on my_module
  &gt;&gt;&gt; isinstance(my_obj, my_module.*)
  SyntaxError: invalid syntax
  
  #Try to build a tuple of clases with iteration to check against
  &gt;&gt;&gt; for klass in my_module:
  TypeError: 'module' object is not iterable
  </code></pre>
  
  <p>Is there a way to type check against ALL the classes in my_module, without explicitly naming them in a tuple?</p>
  
  <p><strong>Optional Background Info:</strong><br>
  I may be overlooking a better way to approach my problem -- if you are wondering, here's the situation:</p>
  
  <p>We are exporting data from a Google App Engine app to an app we have hosted on Rackspace.  We are serializing the data with <code>pickle</code> and then sending it over to our Rackspace server with HTTP Requests.  </p>
  
  <p>Some of the data in the Google App Engine database is of GAE-specific data-types, imported from google.appengine.api.datastore_types.  If any of these data types go across the wire to our Rackspace server, they will raise an error depickling, because our Rackspace app doesn't have the required GAE libraries.  So, on the way out of GAE, I'm checking to see if any of the outgoing objects have a type from google.appengine.api.datastore_types.  If they do, I either convert them to a builtin data-type or I delete the field off the object. </p>