title: Determine if object is of type Foo without importing type Foo
body: <p>Let's say I have a class defined in a file:</p>
  
  <pre><code>import stuff
  import more stuff
  import stuff that takes a long time to import
  class Foo(object):
      def __init__(self, arg1, arg2 etc.):
          self.arg1 = arg1 
          self.arg2 = arg2
          # Lots of other stuff
      # Lots of methods
  </code></pre>
  
  <p>And in another file I have this code:</p>
  
  <pre><code>from big_file import Foo
  def do_stuff(obj):
      if isinstance(obj, Foo):
          do_stuff
      else:
          do_other_stuff
  </code></pre>
  
  <p>Let's say the file Foo takes a long time to import for reasons out of my control. How can I refactor this code to not import Foo but still reliably check the type? I don't think duck typing is appropriate for my particular case.</p>
  
  <p>Should I e.g. check the string representations of the bases of the <code>obj</code>? Or is there another, more canonical way?</p>