Problems with subclassing

Gerrit gerrit at nl.linux.org
Mon Sep 13 03:06:19 EDT 2004


Alexander Stante wrote:
> I have the following problem. I want to subclass from the pygame class
> Surface, but I can't get it working:
> 
> class sprite(Surface):
> def __init__(self, image_array, palette):
> "some code here"
> 
> when I want to create a instance with:
> 
> gfx.sprite(arrayi, palette)
> 
> 
> I get the following error message:
> TypeError: argument 1 must be sequence of length 2, not 100
> 
> It seems that the constructor of Surface is not overrided by the one in
> sprite, but why?

I think you want to override __new__, not __init__, if if could be
working at all that is. GvR wrote a lengthy introduction to this (among
other things) when Py 2.2 was released: google for "descriptor" and it
should end up somewhere.

It's also possible that Surface is not a viable baseclass at all. You
may want to consult the Pygame mailing list about that.

yours,
Gerrit.

-- 
Weather in Twenthe, Netherlands 13/09 08:25:
	14.0°C Broken clouds mostly cloudy wind 4.5 m/s S (57 m above NAP)
-- 
Gerrit Holl - 2nd year student of Applied Physics, Twente University, NL.
Experiences with Asperger's Syndrome:
	EN http://topjaklont.student.utwente.nl/english/
	NL http://topjaklont.student.utwente.nl/



More information about the Python-list mailing list