Dynamic use of property() fails

andrew cooke andrew at acooke.org
Tue Apr 15 05:01:39 EDT 2008


ignore that - i was mistaken (my test was too complex).

the problem seems to be that the attribute is deleted even though
__delete__ is defined.

i'll look at it tomorrow.

thanks again,
andrew

On Apr 15, 4:50 am, andrew cooke <and... at acooke.org> wrote:
> i tried code very similar after reading the first replies and found
> that it did not work as expected on setting.  for example, in
>
>   person = Person()
>   person.age = 27
>
> "age" is set in the instance's dictionary (as 27; the descriptor is
> not called), which then shadows the definition of age in the class
> dictionary.
>
> my understanding was that the descriptor is only called in the class
> context, so would be called if, say, a subclass tried to redefine
> age.  but maybe i am still confused.
>
> i am about to go to sleep.  i guess i will try your code exactly
> tomorrow, but it looks very close to mine which showed this problem.
> are you sure your solution works?
>
> thanks,
> andrew




More information about the Python-list mailing list