By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,216 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,216 IT Pros & Developers. It's quick & easy.

metaclass error

P: n/a
dear readers,

i have a very simple package organized as follows:

!-----------------------------------------!
bgp/
__init__.py
managers/
__init__.py
ManagerInterface.py
TestManager.py
!-----------------------------------------!

and here's ManagerInterface.py and TestManager.py:

!-----------------------------------------!
# ManagerInterface.py
class ManagerInterface(object):
def __init__(self): pass
def process(self, recset, operation):
print 'In ManagerInterface.process()...'

# TestManager.py
import ManagerInterface
class TestManager(ManagerInterface):
def process(self, recset, operation):
print 'In TestManager.process()...'
super(TestManager,self).process(recset,operation)
!-------------------------------------------!

when i try to import the TestManager module via the interpreter, i get
the following error:

!-------------------------------------------!
$ python
Python 2.4.1c1 (#1, Mar 14 2005, 10:28:18)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-49)] on linux2
import bgp.managers.TestManager

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "bgp/managers/TestManager.py", line 2, in ?
class TestManager(ManagerInterface):
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)
!-------------------------------------------!

any thoughts? i think that when python executes the TestManager class
statement, it collects the base class (ManagerInterface) into a tuple
and then executes the class body in a dictionary... is this where the
error is happening?

thanks!
aaron

Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Le 17 Mar 2005 12:27:07 -0800, as*****@berkeley.edu a écrit :
dear readers,

i have a very simple package organized as follows:

!-----------------------------------------!
bgp/
__init__.py
managers/
__init__.py
ManagerInterface.py
TestManager.py
!-----------------------------------------!

and here's ManagerInterface.py and TestManager.py:

!-----------------------------------------!
# ManagerInterface.py
class ManagerInterface(object):
def __init__(self): pass
def process(self, recset, operation):
print 'In ManagerInterface.process()...'

# TestManager.py
import ManagerInterface # ManagerInterface is a module not a class !
# try
from ManagerInterface import ManagerInterface class TestManager(ManagerInterface): # you can also define __init__ method with a super call def process(self, recset, operation):
print 'In TestManager.process()...'
super(TestManager,self).process(recset,operation)
!-------------------------------------------!
thanks!
aaron

Jul 18 '05 #2

P: n/a
doh, that was the problem. :}

thanks for the help!
aaron

Jul 18 '05 #3

P: n/a
F. Petitijean:
ManagerInterface is a module not a class !


Yes, but the error message could be improved (at least for the sake of
people
not knowing the internal working of Python). Do you care to fill a bug
report?

Michele Simionato

Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.