473,386 Members | 1,773 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,386 software developers and data experts.

Inheritance doesn't work

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 following error:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "mandelimage.py", line 3, in ?
class MandelImage (Image):
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)
I am using python 2.4 from the Debian (Sid) packages.

Is it a bug, or am I doing something wrong?
zefciu

--
-----BEGIN zefciu's GEEK CODE BLOCK-----
Version: 3.12
GS d-(+) s+++:-- a-- C++ UL P- L++(+++) E--- W+ N++ o?
K? w-- M- V? PS-(--) PE++(+) Y PGP+ t 5 X R tv- b++
DI D- G e>+++ h!>-- y? UF+
------END zefciu's GEEK CODE BLOCK------
Dec 4 '06 #1
9 2574
zefciu wrote:
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 following error:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "mandelimage.py", line 3, in ?
class MandelImage (Image):
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)
I am using python 2.4 from the Debian (Sid) packages.

Is it a bug, or am I doing something wrong?
You're doing something wrong. PIL.Image is a module, not a class.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Dec 4 '06 #2
zefciu wrote:
I have a problem with inheritance under python. The class definition is
longer, but the troublesome thing is:

from PIL import Image
that's a module, not a class.
class MandelbrotImage (Image):
pass
PIL's Image class isn't designed to be inherited from. to create new
images, use the Image.new() factory.

</F>

Dec 4 '06 #3
zefciu wrote:
class MandelbrotImage (Image):
pass

I am getting the following error:
File "mandelimage.py", line 3, in ?
class MandelImage (Image):
How do you get that error with that code?
Dec 4 '06 #4
John Salerno wrote:
How do you get that error with that code?
$ python
>>import os
class foo(os):
.... pass
....
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)

</F>

Dec 4 '06 #5
Fredrik Lundh wrote:
John Salerno wrote:
>How do you get that error with that code?

$ python
>>>import os
class foo(os):
.... pass
....
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)

</F>
Sure, but I think the question was more about how code that references
"MandelbrotImage could yield a stack that references MandelImage.
Dec 4 '06 #6
J. Clifford Dyer wrote:
Sure, but I think the question was more about how code that references
"MandelbrotImage could yield a stack that references MandelImage.
Yeah, I guess I could have been more specific. :)
Dec 4 '06 #7
J. Clifford Dyer wrote:
Sure, but I think the question was more about how code that references
"MandelbrotImage could yield a stack that references MandelImage.
well, it's been obvious for quite some time that we've now reached a
point in Python's quest for world domination where newbies start
tinkering with Python before they learn how to cut and paste text, so
I wasn't really expecting anyone to be surprised by a trivial typo.

</F>

Dec 4 '06 #8
Fredrik Lundh wrote:
J. Clifford Dyer wrote:
>Sure, but I think the question was more about how code that references
"MandelbrotImage could yield a stack that references MandelImage.

well, it's been obvious for quite some time that we've now reached a
point in Python's quest for world domination where newbies start
tinkering with Python before they learn how to cut and paste text, so
I wasn't really expecting anyone to be surprised by a trivial typo.

</F>
Well, I can't say I was surprised, but my main (subtle, understated,
sneaky) point was how do you expect anyone to help you when you aren't
even giving us the proper information that produces the error?
Dec 7 '06 #9
John Salerno wrote:
Well, I can't say I was surprised, but my main (subtle, understated,
sneaky) point was how do you expect anyone to help you when you aren't
even giving us the proper information that produces the error?
I've stopped trying to make that point; I just apply a basic error correction
algorithm to the posted code, and try to make sense of the result. sometimes
it misfires (e.g. if there are multiple errors in the code), but it usually gets me
pretty close to the actual issue.

</F>

Dec 12 '06 #10

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

Similar topics

19
by: Mike Tyka | last post by:
Hello community, i'm fairly new to using the STL but i've been experimenting a bit with it. I tried to derive a new class say MyString from string like so: class MyString: public string{...
20
by: km | last post by:
Hi all, In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ? thanks in...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
12
by: Steve Jorgensen | last post by:
The classing Visual Basic and VBA support for polymorphism, let's face it, is a bit on the weak side, and built-in support for inheritance is non-existent. This little essay is about some patterns...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
3
by: enchantingdb | last post by:
I have an exam tomorrow that covers the perceived advantages and disadvantages of object oriented programming, in particular polymorphism, inheritance and encapsulation. I know the advantages but...
9
by: Giggle Girl | last post by:
I have inherited a stylesheet that has many of the same values over and over. Can you use a variable in CSS so I only have to hardcode a border color once, for instance? Here is a snip from the...
6
by: tshad | last post by:
I am playing with Inheritance and want to make sure I understand it. I have the following Classes: ******************************************* Public Class AuthHeader:Inherits SoapHeader Public...
3
by: Jess | last post by:
Hello, I've been reading Effective C++ about multiple inheritance, but I still have a few questions. Can someone give me some help please? First, it is said that if virtual inheritance is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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,...

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.