I am curious as to how often you should handle errors in Python. I have a function:
def char_to_lower(char): if ord('A') <= ord(char) <= ord('Z'): return chr(ord(char) + 32) else: return char
This function takes a char as input and returns it's associated lower case value. If I was to pass an int to this function I would get 'TypeError: ord() expected string of length 1, but int found'. My question is whether it considered proper/good practice to wrap this in a try/except block, catching a TypeError? Or whether it is acceptable to leave it as is and let the program fail with the built in Error mechanism.