global check_action_route_flag # Set a global flag. # This flag is checked before the train moves over the following section (and the train does not run until the route is clear) # The flag is reset after the train has run check_action_route_flag = True # print "check_action_route_flag", check_action_route_flag