Pthon Properties

I thought, and some e-books I have read said that all method and variable in python class are accessible publicly. But there is new style class called property that can handle these problems, unfortunately I just already know after py3k released, event property style implemented since 2.2 version.

class ClassWithProperty(object):
   def __SetTheProperty(self, value):
       print "Setting the property"
       self.__m_the_property = value
  
   def __GetTheProperty(self):
       print "Getting the property"
       return self.__m_the_property
  
   def __DelTheProperty(self):
       print "Deleting the property"
       del self.__m_the_property
  
   TheProperty = property(fget=__GetTheProperty,
                          fset=__SetTheProperty,
                          fdel=__DelTheProperty,
                          doc="The property description.")

   def __GetReadOnlyProperty(self):
       return "This is a calculated value."
  
   ReadOnlyProperty = property(fget=__GetReadOnlyProperty)


Each methods are accessible only with the given attribute in the property value. Perform operations that unlisted in property values are raise the exception.
And there is addition in creating new class which is independent class. The declaration of new class override object.

There are some subjects that new for me like above, which i got from Michael Fötsch:
  1. Why New-Style Classes?
  2. Properties
  3. Static Methods
  4. Class Methods
  5. Descriptors
  6. Attribute Slots
  7. The Constructor __new__
  8. Cooperative Super Call
Thanks very much Michael Fötsch