A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-October/057427.html below:

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

[Python-Dev] Property syntax for Py3k (properties and block statement) [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"""
         ...

Greg
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4