The REPO.iter_commits(branch) returns a generator other than a list. And the  __getItem__ is not defined. But with the itertools, the code has much more simplified! ;-)