added python implementation source code