2
的inSetStates
,inInputAlph
和isCorrectDirection
變量爲什麼進行評估,以False
在下面的代碼:變量評估,以虛假的元組
class POC(object):
def __init__(self):
self.__set_states = (1,2,3,4,5)
self.__input_alph = ('a','b')
self.__directions = ('i','d')
def enterTransition(self):
while True:
print "enter transition tuple format:"
trans = raw_input(" Example (1,'a',2,'b','d') : ")
inSetStates = (trans[0] in self.__set_states) and (trans[2] in self.__set_states)
inInputAlph = (trans[1]in self.__input_alph) and (trans[3] in self.__input_alph)
isCorrectDirection = (trans[4].lower() in self.__directions) or (trans[4].lower() in self.__directions)
if (inSetStates and inInputAlph and isCorrectDirection):
return trans
break
else:
print "ERROR: Something is wrong"
poc = POC()
poc.enterTransition()
調試器顯示我,three
的值是False
與元組(1, 'a', 2, 'b', 'd')
和:
inInputAlph = False
inSetStates = False
isCorrectDirection = False
self = <__main__.POC object at 0x1860690>
trans = "(1,\'a\',2,\'b\',\'i\')"
此外,我不知道這些反斜槓是什麼。