I'm working through LearnPythontheHardWay by Zed Shaw, and I'm stumped.
I'm getting the error:
[Attribute Error:'NoneType' object has no attribute 'enter']
at the line: next_scene_name = current_scene.enter()
under the Engine
class.
from sys import exit
class Scene(object):
def enter(self):
print "This scene is not yet configured. Subclass it and implement\
enter()."
exit(1)
class Engine(object):
def __init__(self, scene_map):
self.scene_map = scene_map
def play(self):
current_scene = self.scene_map.opening_scene()
last_scene = self.scene_map.next_scene('finished')
while current_scene != last_scene:
next_scene_name = current_scene.enter()
current_scene = self.scene_map.next_scene(next_scene_name)
current_scene.enter()
class EmptyScene(Scene):
def enter(self):
pass
class FinishScene(Scene):
def enter(self):
pass
class Map(object):
scenes = {
'empty_scene': EmptyScene(),
'finished': FinishScene(),
}
def __init__(self, start_scene):
self.start_scene = start_scene
def next_scene(self, scene_name):
val = Map.scenes.get(scene_name)
return val
def opening_scene(self):
return self.next_scene(self.start_scene)
a_map = Map('empty_scene')
a_game = Engine(a_map)
a_game.play()`