I have struggled to find a working python example that creates and removes constraints at will. The documentation out there is not that great either.
This is a simulation of a hook and a weight that relies on constraints to be lifted. This blend file also includes material collisions to stop the weights from being lifted from just anywhere.
I hope you all find it useful! :)
Looks interesting.