Re: Descriptors and side effects

2007-11-05 Thread Rich Harkins
Bruno Desthuilliers wrote: > Which is easy to do with properties too. True enough. It's the caching of the return value that's the value add of course. ;) > >> After >> it is applied, then the penalties for function call of the property and >> the computation are wiped out once the second acc

Re: Descriptors and side effects

2007-11-05 Thread Bruno Desthuilliers
Rich Harkins a écrit : > Bruno Desthuilliers wrote: > [snip] > >>I'm sorry, but this looks like a very complicated way to do a simple thing: >> >>class MySimpleClass(object): >> def __init__(self, x): >> self.x = x >> self.y = x ** 2 >> >> > > > Sure, for the absurdly simplified case I

Re: Descriptors and side effects

2007-11-05 Thread Rich Harkins
Bruno Desthuilliers wrote: > Rich Harkins a écrit : >> [EMAIL PROTECTED] wrote: >>> Hello everyone, >>> >>> I'm trying to do seemingly trivial thing with descriptors: have >>> another attribute updated on dot access in object defined using >>> descriptors. >> [snip] >> >>> A setter function should

Re: Descriptors and side effects

2007-11-05 Thread Rich Harkins
Bruno Desthuilliers wrote: [snip] > I'm sorry, but this looks like a very complicated way to do a simple thing: > > class MySimpleClass(object): >def __init__(self, x): > self.x = x > self.y = x ** 2 > > Sure, for the absurdly simplified case I posed as an example. ;) Here's ano

Re: Descriptors and side effects

2007-11-05 Thread Bruno Desthuilliers
Rich Harkins a écrit : > [EMAIL PROTECTED] wrote: >> Hello everyone, >> >> I'm trying to do seemingly trivial thing with descriptors: have >> another attribute updated on dot access in object defined using >> descriptors. > > [snip] > >> A setter function should have updated self.l just like it u

Re: Descriptors and side effects

2007-11-05 Thread Rich Harkins
[EMAIL PROTECTED] wrote: > Hello everyone, > > I'm trying to do seemingly trivial thing with descriptors: have > another attribute updated on dot access in object defined using > descriptors. [snip] > A setter function should have updated self.l just like it updated > self.s: > > def __se

Re: Descriptors and side effects

2007-11-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hello everyone, > > I'm trying to do seemingly trivial thing with descriptors: have > another attribute updated on dot access in object defined using > descriptors. > > For example, let's take a simple example where you set an attribute s > to a string and have anoth

Descriptors and side effects

2007-11-04 Thread mrkafk
Hello everyone, I'm trying to do seemingly trivial thing with descriptors: have another attribute updated on dot access in object defined using descriptors. For example, let's take a simple example where you set an attribute s to a string and have another attribute l set automatically to its leng