title: What's the usage of a virtual subclass?
body: <pre><code>class AnimalMeta(type):
      def __instancecheck__(cls, instance):
          return cls.__subclasscheck__(type(instance))
  
      def __subclasscheck__(cls, sub):
          return (hasattr(sub, 'eat') and callable(sub.eat) and
                  hasattr(sub, 'sleep') and callable(sub.sleep))
  
  
  class Animal(object):
      __metaclass__ = AnimalMeta
      pass
  
  
  class Dog(object):
      def eat(self):
          print "eat"
      def sleep(self):
          print "sleep"
  
  
  dog = Dog()
  dog.eat()
  
  print isinstance(dog, Animal)
  print issubclass(dog, Animal)
  </code></pre>
  
  <p>Output:</p>
  
  <pre class="lang-none prettyprint-override"><code>eat
  True
  True
  </code></pre>
  
  <p>I am trying to understand python virtual subclass, example shows as above. instance a virtual subclass doesn't require implement abstract method at all.</p>
  
  <p>What's the real use cases of virtual subclass? it seems to me the virtual subclass works like something in the middle of duck type and object inherit.</p>
  
  <p>Duck type -- virtual subclass -- object inheritance</p>