Ding implementation in python