From a6f90703fb540720d2088462633a9724c9d70bfb Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 30 Sep 2017 14:13:04 -0700 Subject: [PATCH] Get the debug flag working correctly --- tictactoe.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tictactoe.py b/tictactoe.py index fd08405..faeea0c 100644 --- a/tictactoe.py +++ b/tictactoe.py @@ -170,7 +170,12 @@ def hello(): return ("It isn't O's turn.\n\n{}".format(board), 400, {'Content-type': 'text/plain'}) next_board = board.move() - if bool(os.environ.get('TTT_DEBUG', False)): + + try: + debug = bool(int(os.environ.get('TTT_DEBUG', 0))) + except ValueError: + debug = False + if debug: import pprint out = str(next_board) out += '\n\n---------- DEBUG ----------' @@ -179,4 +184,5 @@ def hello(): out += '\n\nChildren:\n{}'.format(pprint.pformat(board.children)) else: out = next_board.board + return (out, 200, {'Content-type': 'text/plain'})