title: How to enforce a child class to set attributes using abstractproperty decorator in python?
body: <p>I want to enforce a Child class to set several attributes(instance variables), to achieve I am using abstractproperty decorator in python 2.7. Here is the sample code:</p>
  
  <pre><code>from abc import ABCMeta, abstractproperty
  class Parent(object):
      __metaclass__ = ABCMeta
      @abstractproperty
      def name(self):
          pass
  
  class Child1(Parent):
      pass
  
  class Child2(Parent):
      name = 'test'
  
  class Child3(Parent):
      def __init__(self):
          self.name = 'test'
  
  obj_child1 = Child1()
  </code></pre>
  
  <p>Child1 object creation gives an error as expected.</p>
  
  <pre><code>obj_child2 = Child2()
  </code></pre>
  
  <p>Child2 object creation works fine as because abstract attribute 'name' is set</p>
  
  <p>However</p>
  
  <pre><code> obj_child3 = Child3()
  </code></pre>
  
  <p>gives <em>TypeError: Can't instantiate abstract class Child3 with abstract methods name</em></p>
  
  <p>I did not understand:although the attribute 'name' is set in the <strong>init</strong> 
  method, why the Child3 object creation is throwing type error.</p>
  
  <p>My requirement is set attributes inside a method of child class. An explanation of what is wrong with child2 class and if there is a better way to enforce a child class to set attributes in a method will help me. Thanks in advance.</p>