Phillip B Oldham <phillip.old...@gmail.com> writes:

> Thanks, but I'm looking for a way to do it *without* using a getter
> as I don't have easy access to the class (its being generated for me
> elsewhere). Essentially I'd like to overwrite (if possible) the
> default behavior when returning certain attributes on certain
> objects.

You can override the behaviour of a class by defining a subclass.

    class UntouchableTypeWrapper(UntouchableType):

        def _foo_get(self):
            return str(self.foo)

        foo = property(_foo_get)

Then you can create instances of the wrapper class where you want the
new behaviour.

-- 
 \          “… a Microsoft Certified System Engineer is to information |
  `\     technology as a McDonalds Certified Food Specialist is to the |
_o__)                               culinary arts.” —Michael Bacarella |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to