Added python API wrapper, fixes #4717