Assignment not the same as defining?

Dale Strickland-Clark dale at riverhall.NOSPAMco.uk
Wed Oct 3 08:17:28 EDT 2001


"Steve Holden" <sholden at holdenweb.com> wrote:

>"Dale Strickland-Clark" <dale at riverhall.NOSPAMco.uk> wrote in message
>news:3itlrt0hds3sjjjt5apj53oo9840sopomp at 4ax.com...
>> A solution I thought I had to using __setattr__ doesn't seem to work.
>>
>> class wibble:
>> def __init__(self):
>> <init code>
>> self.__setattr__ = self.set
>>
>> def set(self, attr, value):
>> <assignment code>
>>
>> My late bound __setattr__ is never called.
>>
>> I've clearly misunderstood something fundamental here. What am I doing
>> wrong?
>>
>From Python 2.0 Reference Manual, section 3.3.2:
>"""
>The following methods can be defined to customize the meaning of attribute
>access (use of, assignment to, or deletion of x.name) for class instances.
>For performance reasons, these methods are cached in the class object at
>class definition time; therefore, they cannot be changed after the class
>definition is executed.
>"""
>
>foiled-by-an-optimization-ly y'rs  - steve

Thanks Steve. What a handy chap you are to have around but can I just
eject a heartfelt *BOLLOCKS* on this one?

Now I need yet another cludge.
--
Dale Strickland-Clark
Riverhall Systems Ltd



More information about the Python-list mailing list