Added python API wrapper, fixes #4717

Tried to squash the 2 commits but I was unable, so I created a new commit :D