CW python code