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"""
         ...

Greg
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to