to setattr or def setProp()

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Tue Nov 14 01:54:35 EST 2006


In <1163485203.560900.286430 at b28g2000cwb.googlegroups.com>,
jm.suresh at no.spam.gmail.com wrote:

> I have a class for rectangle and it has two points in its __slots__ .
> However, we can derive a number of properties like width, height,
> centerPoint etc from these two points. Now, I want to be able to set
> and get these properties directly from the instances. I can either def
> __setattr__ , __getattr__  or I can define function for each property
> like setWidth(), setHeight() .

Or you can use `property()` to create "computed attributes".

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list