Assignment not the same as defining?

Steve Holden sholden at holdenweb.com
Wed Oct 3 07:56:47 EDT 2001


"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
--
http://www.holdenweb.com/








More information about the Python-list mailing list