On Sat, 19 Mar 2011 02:15:55 -0000, Terry Reedy <tjre...@udel.edu> wrote:
On 3/18/2011 5:27 PM, monkeys paw wrote:
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)
OK, i overlooked that and the error was not very enlightening.
A detailed explanation: every module is an instance of a class we will
call Module. Every class is an instance of some class, its metaclass.
The default metaclass, in the absence of any indication otherwise, is
class type. So your class statement was translated to
type('FileInfo',(UserDict,), d)
where d is a dict mappint '__init__' to the function object.
type.__new__ checks the types (metaclasses) of each of the base classes.
In particular, it sees that type(UxerDict) is Module, not type. Since it
assumed that UserDict is a class (since you said it was), it assumed
that Module is a proper metaclass and called
Module('FileInfo',(UserDict,), d)
But Module is not a metaclass and does not expect the tuple of base
classes, and Module.__new__ passed too much to Module.__init__.
Since others have made the same mistake, I opened an issue to improve
the message.
http://bugs.python.org/issue11604
It has to be said that the confusion is exacerbated by ignoring PEP-8
and using the same (CamelCase) name for the module and the class.
That does provide a rich source of errors in cases like this.
--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list