Completed python version

Tested, seems to work. Could use more testing.