Problems with subclassing
Chris S.
chrisks at NOSPAM.udel.edu
Mon Sep 13 18:03:28 EDT 2004
Alexander Stante wrote:
> Hello,
>
> 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?
>
Try manually specifying the subclassed constructor within your new
constructor. For example:
class sprite(Surface):
def __init__(self, image_array, palette):
Surface.__init__(self, someargs)
Then, ensure you are instantiating the subclass correctly.
More information about the Python-list
mailing list