On 09/11/2017 08:44 AM, Guido van Rossum wrote: > I worry that in the end @property isn't general enough and the major > use cases end up still having to use __class__ assignment, and then > we'd have a fairly useless feature that we cant withdraw, ever. What can I say--I don't have that worry ;-) As previously mentioned in this thread, I counted up uses of property, __getattr__, and __getattribute__ in 3.7/Lib. I grepped for the following strings, ignored pydoc_data/topics.py, and got these totals: "@property" 375 hits "def __getattr__" 28 hits "def __getattribute__(" 2 hits @property seems pretty popular. >> Why is there no mechanism to add new descriptors that can work in >> this context? > I've updated the prototype to add one. I added it as > "collections.abc.InstanceDescriptor"; that's a base class you can > inherit from, and then your descriptor will work in a module. > Bikeshedding the name is fine. > > I don't understand the question, or the answer. (And finding the > prototype is taking longer than writing this email.) Ronald was basically asking: what about user classes? The first revision of the prototype didn't provide a way to write your own instance descriptors. The only thing that could be a instance descriptor was property. So, I updated the prototype and added collections.abc.InstanceDescriptor, a base class user classes can inherit from that lets them be instance descriptors. The prototype is linked to from the PEP; for your convenience here's a link: https://github.com/larryhastings/cpython/tree/module-properties //arry/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20170911/8495862c/attachment.html>
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