[Python-Dev] PEP 549 v2: now titled Instance Descriptors

Ethan Furman ethan at stoneleaf.us
Fri Sep 8 16:45:13 EDT 2017

On 09/08/2017 12:44 PM, Larry Hastings wrote:

> I've updated PEP 549 with a new title--"Instance Descriptors" is a better name than "Instance Properties"--and to
> clarify my rationale for the PEP.  I've also updated the prototype with code cleanups and a new type:
> "collections.abc.InstanceDescriptor", a base class that allows user classes to be instance descriptors.

I like the new title, I'm +0 on the PEP itself, and I have one correction for the PEP:  we've had the ability to 
simulate module properties for ages:

     Python 2.7.6 (default, Oct 26 2016, 20:32:47)
     [GCC 4.8.4] on linux2
     Type "help", "copyright", "credits" or "license" for more information.
     --> import module_class
     --> module_class.hello
     --> module_class.hello = 'hola'
     --> module_class.hello

And the code:

     class ModuleClass(object):
         def hello(self):
                 return self._greeting
             except AttributeError:
                 return 'hello'
         def hello(self, value):
             self._greeting = value

     import sys
     sys.modules[__name__] = ModuleClass()

I will admit I don't see what reassigning the __class__ attribute on a module did for us.


More information about the Python-Dev mailing list