473,396 Members | 2,055 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,396 software developers and data experts.

Inheritance crossover packages

Hello group,

I'm having a seemingly simple problem. I want to generate a hierarchy of
modules, like this one:

GenerationScripts/
GenerationScripts/dhcp
GenerationScripts/bind9

And the files:

GenerationScripts/dhcp/__init__.py
GenerationScripts/bind9/generator.py
GenerationScripts/bind9/__init__.py
GenerationScripts/mastergen.py
GenerationScripts/__init__.py

All packages (bind9, dhcp) should inherit from the master generator
"mastergen".

I'm at the very beginning:

$ cat GenerationScripts/__init__.py
import bind9
#import dhcpd

$ cat GenerationScripts/bind9/__init__.py
import GenerationScripts.bind9.generator

$ cat GenerationScripts/bind9/generator.py
from GenerationScripts import mastergen

class generator(mastergen):
def __init__(self):
print "init bind9 generator"

Now what happens when I import GenerationScripts and try to create a
instance of GenerationScripts.bind9.generator is the following:

Traceback (most recent call last):
File "./Generate.py", line 3, in <module>
import GenerationScripts
File "/home/joe/x/GenerationScripts/__init__.py", line 3, in <module>
import bind9
File "/home/joe/x/GenerationScripts/bind9/__init__.py", line 4, in
<module>
import GenerationScripts.bind9.generator
File "/home/joe/x/GenerationScripts/bind9/generator.py", line 7, in
<module>
class generator(mastergen):
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)

I really don't get it - and I've searched and found the same problem,
read the descirption - but still don't get it. What's happening here?

Regards,
Johannes

--
"Wer etwas kritisiert muss es noch lange nicht selber besser können. Es
reicht zu wissen, daß andere es besser können und andere es auch
besser machen um einen Vergleich zu bringen." - Wolfgang Gerber
in de.sci.electronics <47***********************@news.freenet.de>
Aug 11 '08 #1
1 1208
On Aug 11, 2:41*pm, Johannes Bauer <dfnsonfsdu...@gmx.dewrote:
Hello group,

I'm having a seemingly simple problem. I want to generate a hierarchy of
modules, like this one:

GenerationScripts/
GenerationScripts/dhcp
GenerationScripts/bind9

And the files:

GenerationScripts/dhcp/__init__.py
GenerationScripts/bind9/generator.py
GenerationScripts/bind9/__init__.py
GenerationScripts/mastergen.py
GenerationScripts/__init__.py

All packages (bind9, dhcp) should inherit from the master generator
"mastergen".

I'm at the very beginning:

$ cat GenerationScripts/__init__.py
import bind9
#import dhcpd

$ cat GenerationScripts/bind9/__init__.py
import GenerationScripts.bind9.generator

$ cat GenerationScripts/bind9/generator.py
from GenerationScripts import mastergen

class generator(mastergen):
* * * * def __init__(self):
* * * * * * * * print "init bind9 generator"
mastergen is a module, so you can't subclass it. Try changing the
import line to:

from GenerationScripts.mastergen import mastergen
BTW, the error message is misleading, and it seems like it'd be a
common error. Maybe it deserves a special case error message. (I.e.
if the call to metaclass.__init__ raises TypeError, check to see if
it's a module and raise a better error message.)
Carl Banks
Aug 12 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tobias Windeln | last post by:
Hi! I'm looking for suggestions on object-based inheritance in Python. Automatic forwarding (often called delegation) in Python is easy: def __getattr__(self, attr): return...
3
by: Sibylle Koczian | last post by:
I want to try out several applications, all doing the same thing but using different GUI libraries (Tkinter, Qt, wxWindows). Using an example I found in a book I wrote a class containing the GUI...
2
by: John A. Bailo | last post by:
I wrote two windows services that are slight variations on each other. I changed the assembly name ( .exe ) and the namespace within each other. Both have some static methods that share the...
0
by: Terry Hancock | last post by:
I've been discussing PyProtocols with a a friend collaborating with me on a SF game project, about the benefits and design concept of "component architecture", and I'm a little confused by what...
0
by: giovanni gherdovich | last post by:
Hello, first of all: Is this the right place to ask plastek-related questions? I'm trying to make plastex work on my Ubuntu Dapper Drake. For LaTeX, I have the all-in-one package tetex.
9
by: zefciu | last post by:
I have a problem with inheritance under python. The class definition is longer, but the troublesome thing is: from PIL import Image class MandelbrotImage (Image): pass I am getting the...
2
by: jrmemon007 | last post by:
I have 2 computers, one is a acer laptop and the other is a desktop. i want to connect the computers without a router, and only using the crossover cable. After some hardwork the laptop establishes a...
18
by: GD | last post by:
Please remove ability to multiple inheritance in Python 3000. Multiple inheritance is bad for design, rarely used and contains many problems for usual users. Every program can be designed only...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.