<qiyuangong>290_Word_Pattern_1.py
def wordPattern( pattern, str):
    if pattern is None or str is None:
        return True
    words_to_pattern = {}
    pattern_to_words = {}
    word_list = str.split(' ')
    if len(word_list) != len(pattern):
        return False
    for index, word in enumerate(word_list):
        curr_p = pattern[index]
        if pattern_to_words.get(curr_p, word) != word or words_to_pattern.get(word, curr_p) != curr_p:
            return False
        pattern_to_words[curr_p] = pattern_to_words.get(curr_p, word)
        words_to_pattern[word] = words_to_pattern.get(word, curr_p)
    return True
def sample_funcname ( var_0 , var_1 ) :
    if var_0 is None or var_1 is None :
        return True
    var_4 = { }
    var_5 = { }
    var_8 = var_1.split ( ' ' )
    if len ( var_8 ) != len ( var_0 ) :
        return False
    for var_12 , var_13 in enumerate ( var_8 ) :
        var_14 = var_0 [ var_12 ]
        if var_5.get ( var_14 , var_13 ) != var_13 or var_4.get ( var_13 , var_14 ) != var_14 :
            return False
        var_5 [ var_14 ] = var_5.get ( var_14 , var_13 )
        var_4 [ var_13 ] = var_4.get ( var_13 , var_14 )
    return True
