좀 파이썬 2.5 코드를 이해하기 위해 노력하고있어 나는이 패턴을 가로 질러 온 다음에 "상승"나는 몇 가지 간단한 조건문과 셸이를 테스트 시도는 조건문 (파이썬)
def __init__(self, matrix, top_buttons, side_buttons, config_button):
raise isinstance(matrix, ButtonMatrixElement) or AssertionError
raise matrix.width() == 8 and matrix.height() == 8 or AssertionError
raise isinstance(top_buttons, tuple) or AssertionError
raise len(top_buttons) == 8 or AssertionError
raise isinstance(side_buttons, tuple) or AssertionError
raise len(side_buttons) == 8 or AssertionError
raise isinstance(config_button, ButtonElement) or AssertionError
이런 식으로 :
그래서이 테스트에서 판단 해 보니 적어도 내가 시도한 방법과 비교하면 부울 문을 제기 할 수 없습니다. 조건부 표현식을 올리는 것은 무엇을 의미하며 __init__
함수에서 작동하지만 내 테스트 코드에서는 작동하지 않는 이유는 무엇입니까?
그 패턴은 ** 전혀 의미가 없습니다. –
'raise'-ing이있을 때 조건부를 사용하는 유일한 방법은 예를 들어. 'SomeError를 발생 시키면 elseError'가 발생하지만, 불필요하게 혼란스럽게 보입니다. – jonrsharpe