1 i = int(123) 2 j = 123 3 print i, j, i == j # 123 123 True 4 k = 456 5 print i, k, i == k # 123 456 False 6 h = int(789) 7 print i, h, i == h # 123 789 False 8 print j, h, j == h # 123 789 False 9 10 try: 11 a = int("a") # should raise an exception 12 except ValueError, exc: 13 print 'int("a") failed:', exc.value 14 15 try: 16 a = int("!") # should raise an exception 17 except ValueError, exc: 18 print 'int("!") failed:', exc.value 19 20 a = int("a", 16) 21 b = int("123") 22 print a # 10 23 print b, i, b == i # 123, 123, True 24 print b, j, b == j # 123, 123, True 25 26 a_is_int = isinstance(a, int) 27 j_is_int = isinstance(j, int) 28 29 print a_is_int # True 30 print j_is_int # True