title: How does the @property decorator work in Python?
body: <p>I would like to understand how the built-in function <code>property</code> works. What confuses me is that <code>property</code> can also be used as a decorator, but it only takes arguments when used as a built-in function and not when used as a decorator.</p>
  <p>This example is from the <a href="http://docs.python.org/3/library/functions.html#property" rel="noreferrer">documentation</a>:</p>
  <pre><code>class C:
      def __init__(self):
          self._x = None
  
      def getx(self):
          return self._x
      def setx(self, value):
          self._x = value
      def delx(self):
          del self._x
      x = property(getx, setx, delx, &quot;I'm the 'x' property.&quot;)
  </code></pre>
  <p><code>property</code>'s arguments are <code>getx</code>, <code>setx</code>, <code>delx</code> and a doc string.</p>
  <p>In the code below <code>property</code> is used as a decorator. The object of it is the <code>x</code> function, but in the code above there is no place for an object function in the arguments.</p>
  <pre><code>class C:
      def __init__(self):
          self._x = None
  
      @property
      def x(self):
          &quot;&quot;&quot;I'm the 'x' property.&quot;&quot;&quot;
          return self._x
  
      @x.setter
      def x(self, value):
          self._x = value
  
      @x.deleter
      def x(self):
          del self._x
  </code></pre>
  <p>How are the <code>x.setter</code> and <code>x.deleter</code> decorators created in this case?</p>