title: Usage of property() contruct in python
body: <p>I'm trying a small database manager with validation in python and I'm facing this problem:</p>
  
  <p>If I use @property like this:</p>
  
  <pre><code>class Attribute (object):
      def __init__ (self, value=None):
          self._value = value
      @property
      def value (self):
          return self._value
      @value.setter
      def value (self, value):
          if isinstance(value,int):
              self._value = value
          else:
              self._value = None
  
  class A (object):
      def __init__ (self):
          self.a = Attribute()
  
  ia = A()
  </code></pre>
  
  <p>Then I can access the validated value as <code>ia.a.value</code> and set it validated as <code>int</code> with <code>ia.a.value=&lt;some int&gt;</code>. But I want it to be accessed by <code>ia.a</code> (without the <code>value</code>)</p>
  
  <p>I've tried most of the variants I'm capable of think about for the following (autogenerated by Sublime Text 2) code:</p>
  
  <pre><code>def attribute ():
      def fget (self):
          return self._value
      def fset (self, value):
          if isinstance(value,int):
              self._value = value
          else:
              self._value = None
      return locals()
  
  class A (object):
      def __init__ (self):
          self.a = property(**attribute())
  
  ia = A()
  </code></pre>
  
  <p>When I do <code>print(type(ia.a))</code> it outputs something like "<code>&lt;property object at 0x7ffa84a8a7e0&gt;</code>", but as soon as I change the value with <code>ia.a=3</code>, for example, it becames <code>int</code>. In fact, the setter is not being called and the assignment is as usual (I can assign a string to the property, for example).</p>
  
  <p>What I want to do is some dynamic class setup by passing a parameter to the <code>attribute</code> function with the name of every user defined class attribute in order to define instance attributes using <code>getattr</code>, <code>setattr</code> and <code>delattr</code> in that function.</p>
  
  <p>How can I do that? What's the correct usage of the <code>parameter</code> constructor?</p>