I am pretty new to the whole OOP and class prt of python. So I was reaing this book where I got this snippet..
class Map(object):
scenes = {
'central_corridor': CentralCorridor(),
'laser_weapon_armory': LaserWeaponArmory(),
'the_bridge': TheBridge(),
'escape_pod': EscapePod(),
'death': Death()
}
def __init__(self, start_scene):
self.start_scene = start_scene
def next_scene(self, scene_name):
return Map.scenes.get(scene_name)
def opening_scene(self):
return self.next_scene(self.start_scene)
In the last line why did we have to use return self.next_scene(self.start_scene)
instead of return next_scene(start_scene)
. Also can anyone explain the code and the output a bit when input is
a_map = Map('central_corridor')