Re: best practices for making read-only attributes of an object

2006-03-15 Thread James Stroud
bruno at modulix wrote: > Tim Chase wrote: >> >>class Foo: > > old-style classes are deprecated, please use new-style classes: > class Foo(object): > This should be re-phrased to 'Use new-style classes, or else!' py> class Foo: ... def __init__(self, color): ... self._color = color ...

Re: best practices for making read-only attributes of an object

2006-03-15 Thread bruno at modulix
Tim Chase wrote: > I've set up an object and would like to make certain attributes > read-only (or at least enforce it without doing extra work, as per > name-mangling or the like). Ideally, the property would be set in the > __init__, and then not be allowed to change. > > The best solution I've

best practices for making read-only attributes of an object

2006-03-15 Thread Tim Chase
I've set up an object and would like to make certain attributes read-only (or at least enforce it without doing extra work, as per name-mangling or the like). Ideally, the property would be set in the __init__, and then not be allowed to change. The best solution I've been able to come up wit