为什么缩进错误会导致外部作用域的阴影



我正在开发一款名为《飞毛腿历险记》的游戏,在试图找到属性错误的来源时,我遇到了另一个错误,上面写着";外部范围的对象阴影"我发现错误的来源是缩进。当定义一个名为Bubble的类来控制Bubble对象和sprite组时,我意外地将方法缩进了def __init__()中。我的课是这样的:

import pygame
from pygame.sprite import Sprite
class Bubble(Sprite):
"""A class that manages bubbles released from the diver."""
def __init__(self, sa_game):
"""create a bubble object at the diver's current position."""
super().__init__()
"""Some attributes"""
"
"
# import the bubble image
"""Code to import the bubble image"""
# Store the bubble's position as a decimal value
""" """
def update(self):
"""Move the bubble up the screen."""
# Method to update the decimal position of the bubble

def blit_bubble(self):
"""Method to draw the bubble at the diver's current location"""

功能体本身并不重要。但我想知道的是;从外部范围遮蔽";意思和为什么缩进错误会抛出它。我还是个初学者,所以这个概念对我来说可能是新的

这意味着方法存在于两个地方,__init__内部的方法将覆盖(阴影(它们在此范围之外的任何定义。

最新更新