a single class supporting multiple facets/interfaces
Bengt Richter
bokr at oz.net
Mon Jan 20 19:40:06 EST 2003
On Mon, 20 Jan 2003 18:46:43 +0200, Beni Cherniavsky <cben at techunix.technion.ac.il> wrote:
[...]
>It's not perfect but here is my best:
>
>class Facet:
> def __init__(self, obj):
> self._obj = obj
> def __getattr__(self, attr):
> return getattr(self._obj, attr)
> # ditto for setattr, delattr if needed
>
>class C:
> def foo(self):
> print "foo"
> class facet1(Facet):
> def bar(self):
> print "bar version 1"
> facet1 = property(facet1)
That is an interesting twist, using a class constructor
in the place of get-accessor.
Thanks ;-)
Regards,
Bengt Richter
More information about the Python-list
mailing list