On Tue, Oct 11, 2011 at 4:20 PM, rail shafigulin <rail.shafigu...@gmail.com> wrote: > 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() >
Well, for one, you misspelled __init__ in the BaseSprite class above (you have it written as __init). That means that method won't be called at all, which is likely what is causing problems. Also, when using python3, you don't need to specify any arguments to super. Just calling super() will work. Hugo _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor