iamlikeme / rainflow

Implementation of the rainflow-counting algorythm in Python
MIT License
105 stars 34 forks source link

for else in extract_cycles #3

Closed yellowhat closed 7 years ago

yellowhat commented 7 years ago

Hi, I was looking to your code especially the function extract_cycles in the file rainflow.py. I don't understand why there is an else statement on the same level of the for cycle (line 65), infact the break statement is on the while level. Reading/running the code seems that with or without that `else the code returns exactly the same results. Is it a typo or there a much deeper technical reason due to a specific case?

Thanks

iamlikeme commented 7 years ago

Hi, The code block under else is executed once the for loop has iterated through all elements without being interrupted by any break. In this specific case this block should always be executed and it would be equally correct to de-dent it by one level and remove the else.

You can find for...else documentation here.