[Tutor] design of Point class

bob gailer bgailer at gmail.com
Mon Aug 23 20:05:19 CEST 2010


  On 8/23/2010 1:09 PM, Gregory, Matthew wrote:
> 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?

It should not be there! An accidental leftover.

But I notice other problems in my code which I am now attempting to fix. 
Back to you seen.

-- 
Bob Gailer
919-636-4239
Chapel Hill NC



More information about the Tutor mailing list