title: A better python property decorator
body: <p>I've inherited some python code that contains a rather cryptic decorator. This decorator sets properties in classes all over the project. The problem is that this I have traced my debugging problems to this decorator. Seems it "fubars" all debuggers I've tried and trying to speed up the code with psyco breaks everthing. (Seems psyco and this decorator dont play nice). I think it would be best to change it.</p>
  
  <pre><code>def Property(function):
      """Allow readable properties"""
      keys = 'fget', 'fset', 'fdel'
      func_locals = {'doc':function.__doc__}
      def probeFunc(frame, event, arg):
          if event == 'return':
              locals = frame.f_locals
              func_locals.update(dict((k,locals.get(k)) for k in keys))
              sys.settrace(None)
          return probeFunc
      sys.settrace(probeFunc)
      function()
      return property(**func_locals)
  </code></pre>
  
  <p>Used like so:</p>
  
  <pre><code>class A(object):
      @Property
      def prop():
          def fget(self):
              return self.__prop
          def fset(self, value):
              self.__prop = value
      ... ect
  </code></pre>
  
  <p>The errors I get say the problems are because of <em>sys.settrace</em>. (Perhaps this is abuse of settrace ?) </p>
  
  <p>My question: Is the same decorator achievable <strong>without</strong> sys.settrace. If not I'm in for some heavy rewrites.</p>