Best way to control assignment to attribute?

Gerrit Holl gerrit at nl.linux.org
Wed Feb 4 10:34:23 EST 2004


Frank Millman wrote:
> 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.

I think it is possible with new-style classes, introduced in Python 2.2.

http://users.rcn.com/python/download/Descriptor.htm
http://www.python.org/2.2.2/descrintro.html

Gerrit.

-- 
PrePEP: Builtin path type
    http://people.nl.linux.org/~gerrit/creaties/path/pep-xxxx.html
Asperger's Syndrome - a personal approach:
	http://people.nl.linux.org/~gerrit/english/




More information about the Python-list mailing list