How to inherit from two classes without metaclass clashing ?

Michele Simionato michele.simionato at gmail.com
Sun Feb 22 23:38:40 EST 2009


On Sun, Feb 22, 2009 at 2:29 PM, Barak, Ron <Ron.Barak at lsi.com> wrote:
> Hi Michele,
>
> I tried understanding how to avoid the metaclasses clashing, and I did read
> the link you referred to below,
> as well as the relevant O'Reilly cookbook chapter (Recipe 20.17. Solving
> Metaclass Conflicts), but seems I do not understand the correct syntax to
> use, as I either get
>
> $ python -u ./failover_pickle_demo09.py
> Traceback (most recent call last):
>   File "./failover_pickle_demo09.py", line 323, in <module>
>     class ListControlMeta(wx.Frame, CopyAndPaste):
> TypeError: Error when calling the metaclass bases
>     metaclass conflict: the metaclass of a derived class must be a
> (non-strict) subclass of the metaclasses of all its bases
>
> or
>
> $ python -u ./failover_pickle_demo09.py
> Traceback (most recent call last):
>   File "./failover_pickle_demo09.py", line 322, in <module>
>     class ListControlMeta(type(wx.Frame), type(CopyAndPaste)):
> TypeError: Error when calling the metaclass bases
>     multiple bases have instance lay-out conflict

This is not a matter of syntax. wx.Frame is a C++-coded class with a
non standard
layout and there is nothing than the recipe can do to solve the
metaclass conflict.
I guess you are using an old version of wx since I cannot reproduce the problem.
Let us see what the wx guys say.



More information about the Python-list mailing list