python: modifying threshold example