def extract_words(path_to_file):
    assert(type(path_to_file) is str), "I need a string!" 
    assert(path_to_file), "I need a non-empty string!" 

    try:
        with open(path_to_file) as f:
            str_data = f.read()
    except __HOLE__ as e:
        print "I/O error({0}) when opening {1}: {2}! I quit!".format(e.errno, path_to_file, e.strerror)
        raise e
    
    pattern = re.compile('[\W_]+')
    word_list = pattern.sub(' ', str_data).lower().split()
    return word_list
dataset/ETHPy150Open crista/exercises-in-programming-style/21-tantrum/tf-21.py/extract_words