From af955045601bda1f686920f80414dbcc21c3eb93 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sat, 13 Feb 2010 03:27:46 +0000 Subject: more type checking --- (limited to 'talogo.py') diff --git a/talogo.py b/talogo.py index a847d86..4a7e6db 100644 --- a/talogo.py +++ b/talogo.py @@ -86,6 +86,8 @@ def numtype(x): return True if type(x) == float: return True + if type(x) == ord: + return True return False def strtype(x): @@ -116,11 +118,11 @@ def chr_to_ord(x): def careful_divide(x, y): try: - if y==0: - return 0 return x/y - except: - return 0 + except ZeroDivisionError: + raise logoerror("#zerodivide") + except TypeError: + raise logoerror("#syntaxerror") def taequal(x, y): try: @@ -133,12 +135,15 @@ def taequal(x, y): typey = True if typex and typey: return x == y - return str_to_num(x) == str_to_num(y) + try: + return str_to_num(x) == str_to_num(y) + except ValueError: + raise logoerror("#syntaxerror") def taless(x, y): try: return float(x)