title: Understanding __call__ with metaclasses
body: <p>From my understanding the <code>__call__</code> method inside a class implements the function call operator, for example: </p>
  
  <pre><code>class Foo:
      def __init__(self):
          print("I'm inside the __init__ method")
  
      def __call__(self):
          print("I'm inside the __call__ method")
  
  x = Foo() #outputs "I'm inside the __init__ method"
  x() #outputs "I'm inside the __call__ method"
  </code></pre>
  
  <p>However, I'm going through the <a href="http://chimera.labs.oreilly.com/books/1230000000393" rel="nofollow noreferrer">Python Cookbook</a> and the writer defined a metaclass to control instance creation so that you can't instantiate an object directly. This is how he did it:</p>
  
  <pre><code>class NoInstance(type):
      def __call__(self, *args, **kwargs):
          raise TypeError("Can't instantaite class directly")
  
  
  class Spam(metaclass=NoInstance):
      @staticmethod
      def grok(x):
          print("Spam.grok")
  
  Spam.grok(42) #outputs "Spam.grok"
  
  s = Spam() #outputs TypeError: Can't instantaite class directly
  </code></pre>
  
  <p>However, what I don't get is how <code>s()</code> wasn't called, yet it's <code>__call__</code> method was called.  How does this work?</p>