Inheritance and Inner/Nested Classes
Paul Morrow
pm_mon at yahoo.com
Mon Jul 12 11:31:53 EDT 2004
Andrew Bennetts wrote:
>
> Well, the problem is that the way you say you want spell it is mutating a
> shared object:
>
> class Child(Parent):
> Foo.baz = 'hello from Child.Foo'
>
> If you want 'Foo' in Child to be a different object to the Foo in Parent,
> then you need to somehow make it be a different object, which means
> assigning to 'Foo' in Child's namespace. The simplest and clearest way to
> do that is to explicitly subclass with "class Foo(Parent.Foo): ...".
>
> -Andrew.
>
Yes, I think that you may be right. But oh the tempation to look into
metaclasses for this... :)
Thanks.
More information about the Python-list
mailing list