[Tutor] design of Point class
Gregory, Matthew
matt.gregory at oregonstate.edu
Mon Aug 23 19:09:44 CEST 2010
Bob Gailer wrote:
> class PointND(list):
> def __init__(self, *a_list):
> super(PointND, self).__init__(a_list)
>
> def getSet(ix):
> def chklen(self):
> if len(self) < ix + 1:
> raise AttributeError
> def get(self):
> chklen(self)
> return self[ix]
> def set(self, value):
> chklen(self)
> self[ix] = value
> return property(get, set)
>
> def set(self, ix):
> return s
>
> x = getSet(0)
> y = getSet(1)
> z = getSet(2)
>
[snip]
Bob and Hugo, thanks for enlightening me to class properties. Obviously, I'm still on the learning curve. Bob, I'm not seeing where the outer "def set(self, ix)" is used. Am I missing something?
thanks, matt
More information about the Tutor
mailing list