a parser created reads recorded chess games file. api used this: import chess.pgn pgn_file = open("games.pgn") first_game = chess.pgn.read_game(pgn_file) second_game = chess.pgn.read_game(pgn_file) # ... sometimes illegal moves (or other problems) encountered. pythonic way handle them? raising exceptions error encountered. however, makes every problem fatal, in execution stops. often, there still useful data has been parsed , returned. also, can not continue parsing next data set, because still in middle of half-read data. accumulating exceptions , raising them @ end of game. makes error fatal again, @ least can catch , continue parsing next game. introduce optional argument this: game = chess.pgn.read_game(pgn_file, parser_info) if parser_info.error: # appears quite verbose. # can @ least make best of sucessfully parsed parts. # ... are of these or other methods used in wild? actually, are fatal errors -- @ least, far being able repro...
Comments
Post a Comment