[Python-Dev] Property syntax for Py3k (properties and block statement)

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Oct 19 01:20:32 CEST 2005

Antoine Pitrou wrote:

> I suppose something like:
> class C(object):
>     x = prop:
>         """ Yay for property x! """
>         def __get__(self):
>             return self._x
>         def __set__(self, value):
>             self._x = x

I've just looked at Steven Bethard's recipe, and it seems
to give you something very like this. Two problems with it
are the abuse of 'class' to define something that's not
really used as a class, and the need to explicitly inherit
from the base class's property descriptor.

In Py3k, I'd like to see 'property' renamed to 'Property',
and 'property' become a keyword used something like

   class C:

     property x:

       """This is the x property."""

       def __get__(self):

       def __set__(self, value):

       def __del__(self):

The accessors should be overridable in subclasses, so
you can do

   class D(C):

     property x:

       def __get__(self):
         """This overrides the __get__ property for x in C"""


More information about the Python-Dev mailing list