[Tutor] inheritance, python and pygame
rail shafigulin
rail.shafigulin at gmail.com
Tue Oct 11 16:20:25 CEST 2011
i'm trying to learn OOP, python and pygame at the same time. so far it has
been ok, but i stumbled onto a problem
here is the code that causes problems
#!/usr/bin/python3.1
import pygame
pygame.init()
class BaseSprite(pygame.sprite.Sprite):
def __init(self, imagefile):
super(type(self), self).__init__()
self.image = pygame.image.load(imagefile)
self.image = self.image.convert()
self.rect = self.image.get_rect()
class Cloud(BaseSprite):
"""
cloud sprite
scrolls down and moves side to side when it is reset
"""
IMAGE = 'cloud.gif'
def __init__(self):
super(type(self), self).__init__(type(self).IMAGE)
def main():
cloud = Cloud()
if __name__ == '__main__':
main()
when i run i get the following error:
...........................
File "/usr/local/lib/python3.1/dist-packages/pygame/sprite.py", line 129,
in add
else: self.add(*group)
File "/usr/local/lib/python3.1/dist-packages/pygame/sprite.py", line 129,
in add
else: self.add(*group)
File "/usr/local/lib/python3.1/dist-packages/pygame/sprite.py", line 129,
in add
else: self.add(*group)
File "/usr/local/lib/python3.1/dist-packages/pygame/sprite.py", line 129,
in add
else: self.add(*group)
File "/usr/local/lib/python3.1/dist-packages/pygame/sprite.py", line 129,
in add
else: self.add(*group)
File "/usr/local/lib/python3.1/dist-packages/pygame/sprite.py", line 129,
in add
else: self.add(*group)
File "/usr/local/lib/python3.1/dist-packages/pygame/sprite.py", line 129,
in add
else: self.add(*group)
RuntimeError: maximum recursion depth exceeded while calling a Python object
i can't figure out where and why the recursion occurs. can someone help me
out? any advice is appreciated
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111011/49caeec5/attachment.html>
More information about the Tutor
mailing list