# Author: James Tam # Version: November 13, 2024 # Learning concepts: understanding the need for self when inside the methods # of a class. class Person: def __init__(self,aName): self.name = aName #JT's hint for figuring this out, remember/review my scoping rules frome #the functional/decompostion section. # #Spoiler alert (i.e. answer): you cannot access refences that are local to another method or #function. def doesNotSetName(self,newName): print("What will happen when this method is called? Why?") stacey.name = newName jamie.name = newName def start(): stacey = Person("Stacey") jamie = Person("Jamie") print("What will happen when this method is called? Why?") #stacey.doesNotSetName("James special friend") print("What will happen when this method is called? Why?") # #Spoiler alert (i.e. answer): Self is only a parameter for class methods not #functions. #name = "James friend" print("What will happen when this method is called? Why?") # #Spoiler alert (i.e. answer): Self is only a parameter for class methods not #functions. #self.name = "James friend" start()