Property Descriptor - Public Getter, Private Setter

Diez B. Roggisch deets at
Wed Jul 18 17:37:50 CEST 2007

gamehack wrote:

> Hi all,
> I was looking around the net to figure out how I can use the
> property() descriptor to make a property readable by everyone and only
> settable by the class or any derived classes. Thanks.

Forget it. You can try and come up with an implementation that will check
the stack-frames and try and see if the callers belong to the current
class, or some subclass.

But then if somebody wants to accomplish the setting by all means, he/she
just adds a new setter method to your class, and that's it.

What's your usecase? If you give us that, there might be better suggestions.


More information about the Python-list mailing list