locations = parse_connections_file(connectionsfile, parse_locations_file(locationsfile)) try: startcity = [x for x in locations if x.name == sys.argv[3]][0] except IndexError: print("Could not find origin city:", sys.argv[3]) exit(1) try: destcity = [x for x in locations if x.name == sys.argv[4]][0] except IndexError: print("Could not find destination city:", sys.argv[4]) exit(1) avoidcities = [x for x in locations if x.name in sys.argv[5:]] # Create the search object search = AStarSearch(startcity, destcity, lambda x: x.distance_to(destcity), potholes=avoidcities) # Run the search algorithm search.start_search() # Get the shortest path traversed path = search.run_to_end() # Output path to standard output print("->".join([x.name for x in path])) # vim: set et sw=4 ts=4: