Read-only attribute in module
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Fri Feb 10 17:23:55 EST 2012
On Thu, 09 Feb 2012 22:27:50 -0500, Terry Reedy wrote:
> On 2/9/2012 8:04 PM, Steven D'Aprano wrote:
>
>> Python happily violates "consenting adults" all over the place. We have
>> properties, which can easily create read-only and write-once
>> attributes.
>
> So propose that propery() work at module level, for module attributes,
> as well as for class attributes.
I'm not wedded to a specific implementation.
Besides, it's not just a matter of saying "property should work in
modules" -- that would require the entire descriptor protocol work for
module lookups, and I don't know how big a can of worms that is. Constant
names is a lot more constrained than computed name lookups.
--
Steven
More information about the Python-list
mailing list