title: What is a "property" used for in Python?
body: <p>I was editing a blog post and started to type the word <code>property</code> when my autocomplete suggested a completion called <code>new Property</code>, curious as ever I looked it up and found that this was coming from the Python autocomplete package.</p>
  
  <p>I pressed it and this code appeared:</p>
  
  <pre><code>def foo():
    doc = "The  property."
  
    def fget(self):
      return self._
  
    def fset(self, value):
      self._ = value
  
    def fdel(self):
      del self._
  
    return locals()
  
   = property(**())
  </code></pre>
  
  <p>I typed <code>Grape</code> where the cursor(s) were, so I ended up with this:</p>
  
  <pre><code>def Grape():
    doc = "The Grape property."
  
    def fget(self):
      return self._Grape
  
    def fset(self, value):
      self._Grape = value
  
    def fdel(self):
      del self._Grape
  
    return locals()
  
  Grape = property(**Grape())
  </code></pre>
  
  <p>By looking at the code I can see that it's creating a local variable called <code>doc</code> but doesn't seem to be doing anything with it.</p>
  
  <p>It's also creating three functions, one which returns <code>self._Grape</code> another which adds a new property to <code>self._Grape</code> and one which deletes <code>self._Grape</code>.</p>
  
  <p>Where did <code>self</code> &amp; <code>_Grape</code> come from? Is this a class of some sort, like a <em>"pseudo class"</em>?</p>
  
  <p>Where, why and how are <em>"new Properties"</em> used?</p>