작성
·
355
답변 1
2
일반적으로 StopIteration은 for문 next 등올 접근 시 내부적으로 처리가 되기 때문에
코딩시에는 사용하실일이 거의 없는 것 같습니다.
명시적으로 사용하셔도 되는 부분입니다. 사용하기 나름입니다.
Now, normally you don't see StopIteration
exceptions. The reason for this is that you usually consume generators inside for
loops. A for
statement will automatically call next
over and over until StopIteration
gets raised. It will catch and suppress the StopIteration
exception for you, so you don't need to mess around with try
/except
blocks to deal with it.