ported DefendPenalty to python