title: Python static class property set/get
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5559256/private-functions-variables-enforcement-in-python">Private functions / Variables enforcement in python</a>  </p>
  </blockquote>
  
  
  
  <p>Can one create an equivalent to the following class with two static properties, one read-only and the other read-write in Python?</p>
  
  <pre class="lang-c# prettyprint-override"><code>class Foo
  {
      private static string _rdy = "RO";
      public static string rd
      {
          get { return _rd; }
      }
  
      private static string _rw = "RW";
      public static string rw
      {
          get { return _rw ; }
          set { _rw = value; }
      }
  }
  </code></pre>
  
  <p>I know <a href="https://stackoverflow.com/a/3203659/1877238">read-only class properties</a> are possible in Python, but how I have not seen any examples of read-write class properties in Python.  Is it possible?  Basically I want:</p>
  
  <pre class="lang-python prettyprint-override"><code>class classproperty(object):
  
      def __init__(self, getter
              #, setter
          ):
          self.getter = getter
      #    self.setter = setter
  
      def __get__(self, instance, owner):
          return self.getter(owner)
  
      # Could there be a __set__ here?
      #vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
      #def __set__(self, instance, owner, value):
      #    self.setter(owner, value)
      #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  
  class Foo(object):
  
      _ro = "RO"
      _rw = "RW"
  
      @classproperty
      def ro(cls):
          return cls._ro
  
      # How would you this?
      #vvvvvvvvvvvvvvvvvvvv
      #@classproperty.setter
      #^^^^^^^^^^^^^^^^^^^^
      #def rw(cls, value):
      #    cls._rw, value
  
  # This is what I need
  &gt;&gt;&gt; Foo.ro
  RO
  &gt;&gt;&gt; Foo.ro = 'X'     # Hypothetical Exception
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  AttributeError: class 'Foo' attribute 'ro' is not writable!
  &gt;&gt;&gt; Foo.rw
  RW
  &gt;&gt;&gt; Foo.rw = 'NEW'
  &gt;&gt;&gt; Foo.rw
  NEW
  </code></pre>