I need a variable(“dragon”) that all classes, created by a certain class (“AlienHead”), can change.
here is a simplified version of what I am doing:
class AlienHead:
def __init__(self):
[INDENT=2]
self.dragon = 0
self.list = [3, 40, 89, 12, 902]
[/INDENT]
def create(self):
[INDENT=2]
self.shape01 = Shape(self.list, dragon) #line10
self.shape02 = Shape(self.list, dragon) #line11
self.shape03 = Shape(self.list, dragon) #line12
[/INDENT]
class Shape:
def __init__(self, list, dragon):
[INDENT=2]
if list[dragon] >= 50:[/INDENT]
[INDENT=3]
do stuff[/INDENT]
[INDENT=3]dragon += 1 #here's the problem
[/INDENT]
[INDENT=6]#"dragon" needs to increase by 1
[/INDENT]
[INDENT=6]#for the classes that are created in lines 11 and 12
[/INDENT]
I need to be able to reference the “dragon” variable from classes that are created by “AlienHead”.