test_is.py

# ==================================================================
#
# ==================================================================

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.istitle():
            print('istitle = {}    ({})'.format(line.istitle(),line))
        elif line.isdigit():
            print('isdigit = {}    ({})'.format(line.isdigit(),line))
        elif line.isupper():
            print('isupper = {}    ({})'.format(line.isupper(),line))
        elif line.isalnum():
            print('isalnum = {}    ({})'.format(line.isalnum(),line))
        elif line.islower():
            print('islower = {}    ({})'.format(line.islower(),line))
        elif line.isalpha():
            print('isalpha = {}    ({})'.format(line.ialpha(),line))
        else:
            print('Don\'t recognize ({})'.format(line))
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')