Update detect.py

This generator causes an error in detect_windows because it is run twice there. Better store it as a data structure instead.