473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

metaclass error

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
3 6922
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
doh, that was the problem. :}

thanks for the help!
aaron

Jul 18 '05 #3
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Fernando Rodriguez | last post by:
Hi, I'm having trouble with a metaclass suposed to check the method signature of its classes. Here's the metaclass: class MetaChecker(type): def __new__(cls, name, bases, attribs): for...
7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
0
by: Robin Becker | last post by:
A colleague wanted to initialize his class __new__ and tried code resembling this #######################1 class Metaclass (type): def __init__(cls, name, bases, *args, **kwargs):...
5
by: Irmen de Jong | last post by:
Hi, I've developed the Metaclass below, because I needed a way to make a bunch of classes thread-safe. I didn't want to change every method of the class by adding lock.aqcuire()..lock.release()...
33
by: Jacek Generowicz | last post by:
I would like to write a metaclass which would allow me to overload names in the definition of its instances, like this class Foo(object): __metaclass__ = OverloadingClass att = 1 att = 3
2
by: zipher | last post by:
After searching through comp.lang.python and the web regarding metaclasses, I could not find an example for customing classes using metaclass parameters. I want to be able to create a class at...
16
by: ironfroggy | last post by:
Hoping this isn't seeming too confusing, but I need to create a metaclass and a class using that metaclass, such that one of the bases of the metaclass is the class created with that metaclass. I...
14
by: Pedro Werneck | last post by:
Hi I have a class A, with metaclass M_A, and class B, subclass of A, with metaclass M_B, subclass of M_A. A class C, subclass of B must have M_B or a subclass of it as metaclass, but what if...
9
by: Christian Eder | last post by:
Hi, I think I have discovered a problem in context of metaclasses and multiple inheritance in python 2.4, which I could finally reduce to a simple example: Look at following code: class...
4
by: Pedro Werneck | last post by:
Hi all I noticed something strange here while explaining decorators to someone. Not any real use code, but I think it's worth mentioning. When I access a class attribute, on a class with a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.