[Python-ideas] of properties and metaclasses

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Jul 24 02:07:03 CEST 2007


Ron Adam wrote:

> property foo():
>      __value__ = value
>      def __get__():
>          return __value__
>      def __set__(value)
>          __value__ = value
> 
> The same object in a class might look like...
> 
> property foo(self):
>     self.__value__ = None
>     def __get__(self):
>         return self.__value__
>     def __set__(self, value):
>         self.__value__ = value

In the first version, how is anything supposed to know that
the __value__ inside the function is an implicit attribute
of self rather than a local variable of the function

I can't see this flying, for all the reasons that suggestions
for implicit 'self' in methods get shot down in milliseconds.

--
Greg



More information about the Python-ideas mailing list