[Tutor] classproperty: readonly and inheritance - not more needed
Steven D'Aprano
steve at pearwood.info
Thu Apr 20 08:26:20 EDT 2017
On Thu, Apr 20, 2017 at 10:39:57AM +0200, Thomas Güttler wrote:
> >- its hard to get classproperty to work right.
>
> What is "righ"?
>
> In my case a read-only classproperty is enough. Inheritance should be
> supported.
>
> I don't have a usecase for a setter.
The standard library is not just for you :-)
If Peter's solution is "good enough" for you, then great, go ahead and
use it. But beware: of the two implementations I know, you cannot have
both:
- access from instances;
- read-only property;
You can have access from instances, but then the classproperty is not
read-only. Or you can have read-only access, but only from the class
object.
Although I haven't studied Eryksun's solution yet, he may have found a
work-around.
Good luck!
--
Steve
More information about the Tutor
mailing list