title: Understanding metaclass and inheritance in Python
body: <p>I have some confusion regarding meta-classes.</p>
  
  <h3>With inheritance</h3>
  
  <pre><code>class AttributeInitType(object):
  
     def __init__(self,**kwargs):
         for name, value in kwargs.items():
            setattr(self, name, value)
  
  class Car(AttributeInitType):
  
      def __init__(self,**kwargs):
          super(Car, self).__init__(**kwargs)
      @property
      def description(self):
         return "%s %s %s %s" % (self.color, self.year, self.make, self.model)
  
  c = Car(make='Toyota', model='Prius', year=2005, color='green')
  print c.description
  </code></pre>
  
  <h3>With meta class</h3>
  
  <pre><code>class AttributeInitType(type):
     def __call__(self, *args, **kwargs):
         obj = type.__call__(self, *args)
         for name, value in kwargs.items():
             setattr(obj, name, value)
         return obj
  
  class Car(object):
     __metaclass__ = AttributeInitType
  
     @property
     def description(self):
         return "%s %s %s %s" % (self.color, self.year, self.make, self.model)
  
  
  c = Car(make='Toyota', model='Prius', year=2005,color='blue')
  print c.description
  </code></pre>
  
  <p>As above example is not useful as practically but just for understanding,</p>
  
  <p>I have some questions Like,</p>
  
  <ol>
  <li><p>What is the difference/similarity between a meta class and inheritance?</p></li>
  <li><p>Where should one use a meta class or inheritance?</p></li>
  </ol>