Re: class level properties

2008-04-13 Thread Peter Otten
Charles D Hixson wrote: > Peter Otten wrote: >> Charles D Hixson wrote: >> >> >>> I want a hundred or so read-only variables, and I'm not sure the best >>> way to achieve it. >>> >> >> What do you really want to do? I recommend that you forget about bondage >> and rely upon displine: >> >>

Re: class level properties

2008-04-13 Thread Charles D Hixson
Peter Otten wrote: > Charles D Hixson wrote: > > >> I want a hundred or so read-only variables, and I'm not sure the best >> way to achieve it. >> > > What do you really want to do? I recommend that you forget about bondage and > rely upon displine: > > class Test(object): > """Never ch

Re: class level properties

2008-04-13 Thread Peter Otten
Charles D Hixson wrote: > I want a hundred or so read-only variables, and I'm not sure the best > way to achieve it. What do you really want to do? I recommend that you forget about bondage and rely upon displine: class Test(object): """Never change an attribute with an uppercase name."""

Re: class level properties

2008-04-12 Thread Arnaud Delobelle
On Apr 13, 12:33 am, Charles D Hixson <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle wrote: > class MetaX(type): > > > ...     @property > > ...     def spam(self): return 'eggs' > > ... > > class X(object): > > > ...      __metaclass__ = MetaX > > ... > > X.spam > > > 'eggs' > > > HT

Re: class level properties

2008-04-12 Thread Charles D Hixson
Arnaud Delobelle wrote: > On Apr 12, 8:36 pm, Charles D Hixson <[EMAIL PROTECTED]> > wrote: > >> I'm trying to construct read-only variables at the class level. I've >> been unsuccessful. Any suggestions? >> >> Mixing @classmethod and @property doesn't appear to produce workable >> code. Ditt

Re: class level properties

2008-04-12 Thread Arnaud Delobelle
On Apr 12, 8:36 pm, Charles D Hixson <[EMAIL PROTECTED]> wrote: > I'm trying to construct read-only variables at the class level.  I've > been unsuccessful.  Any suggestions? > > Mixing @classmethod and @property doesn't appear to produce workable > code.  Ditto for mixing @classmethod and __getatt

class level properties

2008-04-12 Thread Charles D Hixson
I'm trying to construct read-only variables at the class level. I've been unsuccessful. Any suggestions? Mixing @classmethod and @property doesn't appear to produce workable code. Ditto for mixing @classmethod and __getattr__. (The property approach compiles, but execution says that you can