まぐらぼ

日々の雑記を書いています。

タプル

タプルはあまり使ってこなかった。汎用的な小さなクラスみたいなもんか。

def test_space_regex() :
    #  [\t\n\r\f\v] 
 
    mtuple = ( # tuple
              "A Z",        True,
              "Z  Z",      True,
              "A    Z",     True,
              "BAZ",     False,
              "A\rZ",     True,
              )

    max = len( mtuple)/2
    for cnt in range(0,max):
        index = cnt*2
        mobject = re.match('([A-Z][\s]*Z)', mtuple[index] )
        if mobject:
            assert mtuple[index+1] == True
            print "%s : %s" % (mobject.group(0),"")
        else:
            assert mtuple[index+1] == False
            print "%s : %s" % ("no match","")

    return True