Properties - when and why

Duncan Booth duncan at NOSPAMrcp.co.uk
Mon Jul 8 09:59:50 EDT 2002


"Arthur Siegel" <ajs at ix.netcom.com> wrote in
news:mailman.1026132261.447.python-list at python.org: 

> Alex writes -
> 
>>The obvious solution for this case is to keep your original
>>get_V method intact and to code V_homogeneous the simple way:
> 
>>def V_homogenous(self):
>>    V = self.V
>>   return array((V.x,V.y,V.z,1.))
> 
> 
<snip>
> Are you in fact saying that your suggested solution avoids multiple
> calls to the calculation that determines the value of self.V?

He is saying that.

self.V calls self.get_V(), and the object it returns is bound to V. Further 
references to V will use the value that was returned and not the attribute.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list