Python NameError: name 'self' is not defined Why?
Python NameError: name 'self' is not defined Why? Question: At the top: import pygame, sys from pygame.sprite import Sprite from pygame.locals import * pygame.init() Part not working: class DetectionBox(Sprite): def __init__(self): Sprite.__init__(self) self.img = pygame.Surface([SCREEN_WIDTH, SCREEN_HEIGHT/4], SRCALPHA, 32).convert_alpha() self.pos = (0, SCREEN_HEIGHT – (SCREEN_HEIGHT/4)*3) DETECT_BOX = DetectionBox() Error: NameError: name ‘self’ is not defined Someone …