[Python-Dev] PEP 549: Instance Properties (aka: module properties)
ronaldoussoren at mac.com
Wed Sep 6 17:13:39 EDT 2017
> On 6 Sep 2017, at 00:03, Larry Hastings <larry at hastings.org> wrote:
> I've written a PEP proposing a language change:
> https://www.python.org/dev/peps/pep-0549/ <https://www.python.org/dev/peps/pep-0549/>
> The TL;DR summary: add support for property objects to modules. I've already posted a prototype.
> How's that sound?
To be honest this sounds like a fairly crude hack. Updating the __class__ of a module object feels dirty, but at least you get normal behavior w.r.t. properties.
Why is there no mechanism to add new descriptors that can work in this context?
BTW. The interaction with import is interesting… Module properties only work as naive users expect when accessing them as attributes of the module object, in particular importing the name using “from module import prop” would only call the property getter once and that may not be the intended behavior.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev