Re: Read-only class properties

2005-07-11 Thread Bengt Richter
On Sun, 10 Jul 2005 21:10:36 -0700, Michael Spencer <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: >... >> >> class Foo(object): >> class __metaclass__(type): >> def __setattr__(cls, name, value): >> if type(cls.__dict__.get(name)).__name__ == 'Descriptor': >>

Re: Read-only class properties

2005-07-10 Thread Michael Spencer
Bengt Richter wrote: ... > > class Foo(object): > class __metaclass__(type): > def __setattr__(cls, name, value): > if type(cls.__dict__.get(name)).__name__ == 'Descriptor': > raise AttributeError, 'setting Foo.%s to %r is not allowed' > %(name, value) >

Re: Read-only class properties

2005-07-10 Thread Bengt Richter
On 10 Jul 2005 13:38:22 -0700, "George Sakkis" <[EMAIL PROTECTED]> wrote: >I'm trying to write a decorator similar to property, with the >difference that it applies to the defining class (and its subclasses) >instead of its instances. This would provide, among others, a way to >define the equivale

Read-only class properties

2005-07-10 Thread George Sakkis
I'm trying to write a decorator similar to property, with the difference that it applies to the defining class (and its subclasses) instead of its instances. This would provide, among others, a way to define the equivalent of class-level constants: class Foo(object): @classproperty def The