Metaclass conflict TypeError exception: problem demonstration script

Hrvoje Niksic hniksic at xemacs.org
Mon Feb 23 08:53:01 EST 2009


"Barak, Ron" <Ron.Barak at lsi.com> writes:

> However, when line 7 is in effect (with line 8 commented out), viz.:
>
> $ cat -n metaclass_test01.py | head
>   1  #!/usr/bin/env python
>   2
>   3  import sys
>   4  import wx
>   5  import CopyAndPaste
>   6
>   7  class ListControl(wx.Frame, CopyAndPaste):

If this is the actual source you're running, then CopyAndPaste is a
module, not a type, and that causes the conflict.  Use
CopyAndPaste.CopyAndPaste, or change the import line to read "from
CopyAndPaste import CopyAndPaste".  Or, even better, adhere to
recommendations laid down in PEP 8 and you'll avoid confusion between
module and class names.



More information about the Python-list mailing list