# ================================================================== # # ================================================================== import os import sys # ------------------------------------------------------------------- # support functions # ------------------------------------------------------------------- def RunningPython3(): ##print(sys.version_info) if sys.version_info[0] == 3: return True return False def GetUerInput(prompt): return imput(prompt) def Pause(): GetUserInput('Press enter to continue') def FileExists(fil): if not fil: return False if not os.path.isfile(fil): return False return True # --- failure test def DivideByZero(x): print('DivideByZero({})'.format(x)) return x / 0.0 # ------------------------------------------------------------------ # main # ------------------------------------------------------------------ # --- running Python 3? py3 = RunningPython3() if not py3: print('Not running Python 3 - exit') exit(1) try: while True: line = input('Enter something: ') line.strip() if line == '': break if line.isdigit(): line = float(line) x = DivideByZero(line) print('returned: {}',format(x)) except OSError as e: print('OSError ',e) except ValueError as e: print('ValueError ',e) except Exception as e: print('Exception ', e) finally: print('That\'s All Folks')