Best way to control assignment to attribute?

Frank Millman frank at chagford.com
Thu Feb 5 02:34:53 EST 2004


frank at chagford.com (Frank Millman) wrote:
> Hi all
> 
> I want to control the assignment of a value to an attribute. Instead
> of allowing it to be changed directly, I want to enforce that a method
> is called, which will perform the assignment subject to various
> checks.
> 

Thanks to everybody for the replies. Clearly property() is the way to
go.

I have avoided new-style classes up to now, as I was waiting for a
real need to use them. Now I have one, so it is time to roll up my
sleeves and get stuck in.

Thanks again.

Frank



More information about the Python-list mailing list