On Wed, Jan 10, 2001 at 05:07:07PM +0000, Chris Withers wrote:
> > If you want _set_your_attribute to be called, you
> > need to override __setattr__:
> > 
> >     def __setattr__(self, name, value):
> >         setter = getattr(self, '_set_' + name, None)
> >         if setter:
> >             setter(value)
> >         else:
> >             raise AttributeError, "no such attribute: " + `name`
> 
> Hmmm... how would you change this to call the __setattr__ that was there
> before you overrode it, if a setter could not be found?

The same way you call any overridden method, by calling it on the class
you inherit it from.

So:

  class Foo:
      def __setattr__(self, name, value):
          # Whatever
          pass

  class Bar(Foo):
      def __setattr__(self, name, value):
          Foo.__setattr__(self, name, value)
          # More whatever

-- 
Martijn Pieters
| Software Engineer  mailto:[EMAIL PROTECTED]
| Digital Creations  http://www.digicool.com/
| Creators of Zope   http://www.zope.org/
---------------------------------------------

_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to