Python3 compat iterator

@thatch45 makes it python3 compatible without creating a list to then iterate over :) (from your comment in #19221)