``for...else`` syntax may be cleaner here:

```
for k in range(window):
    for j in range(...):
        ...
    else:
        continue
    break
```

See http://stackoverflow.com/a/654002/214686