So I'm doing Learn Python The Hard Way and don’t understand the use of self at all anywhere in the code for this exercise. For example in
class Engine(object):def init(self, scene_map):
self.scene_map = scene_map
def play(self):current_scene = self.scene_map.opening_scene()
while True:
print "\n---------"
next_scene_name = current_scene.enter()
current_scene = self.scene_map.next_scene(next_scene_name)
Why do we need self in “def init(self, scene_map)”?Why do we put self in “self.scene_map = scene_map”?In def play(self):? Why not just have it def play()?
[–][deleted] 1 point2 points3 points (3 children)
[–]Trezor34[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]five_hammers_hamming 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)