Subclassing a read-only class

Martin von Loewis loewis at informatik.hu-berlin.de
Mon Feb 18 11:50:47 EST 2002


Gerhard Häring <gh_pythonlist at gmx.de> writes:

> For compatibility testing, I'd like to put an additional method into
> window object I get from the curses module. Unfortunately, if I try to
> do so, I get:
> 
>     TypeError: object has read-only attributes
> 
> I'm pretty sure there is a solution, probably with a proxy object. But
> currently I just don't get it.
> 
> Any ideas?

You haven't described the compatibility testing in detail. However, it
might be that deriving from Bastion.BastionClass could do the trick:
Just add the additional functions in the subclass, and implement a
_get_ that delegates everything to the window object.

Regards,
Martin




More information about the Python-list mailing list